Skip to content

Commit

Permalink
Merge pull request cockroachdb#119 from nvanbenschoten/nvanbenschoten…
Browse files Browse the repository at this point in the history
…/inlineSetString

apd: add inline fast-path to BigInt.SetString
  • Loading branch information
nvanbenschoten authored Jul 5, 2022
2 parents 9f9f7a5 + a4088d3 commit 06ef971
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bigint.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,10 @@ func (z *BigInt) SetInt64(x int64) *BigInt {

// SetString calls (big.Int).SetString.
func (z *BigInt) SetString(s string, base int) (*BigInt, bool) {
if i, err := strconv.ParseInt(s, base, 64); err == nil {
z.SetInt64(i)
return z, true
}
var tmp1 big.Int //gcassert:noescape
zi := z.inner(&tmp1)
if _, ok := zi.SetString(s, base); !ok {
Expand Down

0 comments on commit 06ef971

Please sign in to comment.