From 00b53d39c3ec4a7609b4878f1ae83f6b2329b732 Mon Sep 17 00:00:00 2001 From: Joe Kyo Date: Mon, 16 Oct 2017 07:25:14 +0100 Subject: [PATCH] crypto/tls: remove bookkeeping code from pHash function Since copy function can figure out how many bytes of data to copy when two slices have different length, it is not necessary to check how many bytes need to copy each time before copying the data. Change-Id: I5151ddfe46af5575566fe9c9a2648e111575ec3d Reviewed-on: https://go-review.googlesource.com/71090 Reviewed-by: Filippo Valsorda Run-TryBot: Filippo Valsorda Run-TryBot: Tobias Klauser TryBot-Result: Gobot Gobot --- prf.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/prf.go b/prf.go index 27a22f1..d07be11 100644 --- a/prf.go +++ b/prf.go @@ -35,12 +35,8 @@ func pHash(result, secret, seed []byte, hash func() hash.Hash) { h.Write(a) h.Write(seed) b := h.Sum(nil) - todo := len(b) - if j+todo > len(result) { - todo = len(result) - j - } - copy(result[j:j+todo], b) - j += todo + copy(result[j:], b) + j += len(b) h.Reset() h.Write(a)