]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Speed up mse.handshake.establishS
authorMatt Joiner <anacrolix@gmail.com>
Fri, 30 Sep 2016 02:14:34 +0000 (12:14 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 30 Sep 2016 02:14:34 +0000 (12:14 +1000)
Remove possible slice allocation, and avoid reflect.

mse/mse.go

index d366aa75b9d86def62c8a64c89ee5eb0a0c657ca..93a80a6bf5a0ab37298af5bf6e83bb2dd371801f 100644 (file)
@@ -17,7 +17,6 @@ import (
        "strconv"
        "sync"
 
-       "github.com/anacrolix/missinggo"
        "github.com/bradfitz/iter"
 )
 
@@ -167,7 +166,8 @@ func (h *handshake) establishS() (err error) {
        var Y, S big.Int
        Y.SetBytes(b[:])
        S.Exp(&Y, &x, &p)
-       missinggo.CopyExact(&h.s, paddedLeft(S.Bytes(), 96))
+       sBytes := S.Bytes()
+       copy(h.s[96-len(sBytes):96], sBytes)
        return
 }