]> Cypherpunks repositories - keks.git/commitdiff
Simplify ≥0 check
authorSergey Matveev <stargrave@stargrave.org>
Tue, 14 Jan 2025 10:19:54 +0000 (13:19 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 14 Jan 2025 12:35:54 +0000 (15:35 +0300)
go/atom-encode.go
go/encode.go

index 485d9b499d6e139cb187dcd34dfcbf7a02c7b252e6493c94f881096d4167d489..4c5876a031a5f876ead5a74668b7279bbd53bbc025363f329c748bd14c1a8f44 100644 (file)
@@ -97,7 +97,7 @@ func IntEncode(w io.Writer, v int64) (written int64, err error) {
 
 // Write an encoded ±INT atom.
 func BigIntEncode(w io.Writer, v *big.Int) (written int64, err error) {
-       if v.Cmp(bigIntZero) >= 0 {
+       if v.Sign() >= 0 {
                _, err = w.Write([]byte{byte(AtomPInt)})
        } else {
                n1 := big.NewInt(-1)
index cd478f1e2732ea42ab1b9ecc823f38e7f3bb97339e34ef5086ade37d5e3b786c..2f9cf018dc6f016ea7cc37cd08c4b0b8b2d0230f316aafa074d43c414a3d9e9e 100644 (file)
@@ -31,8 +31,6 @@ import (
        "go.cypherpunks.su/tai64n/v4"
 )
 
-var bigIntZero = big.NewInt(0)
-
 type EncodeOpts struct {
        // Do not convert time.Time to TAI, assume no conversion is needed.
        LeaveTAI bool