aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Shaw <chickencha@gmail.com>2010-10-30 20:16:44 -0700
committerRobert Griesemer <gri@golang.org>2010-10-30 20:16:44 -0700
commit5bf420f0c894fac193f50af990675012480c8677 (patch)
treeae5132b0b9b51443a950da24ddd7dc18d6144c4c
parenta8c4da996e69fcab48186011bb517ca915ac5f58 (diff)
downloadgo-5bf420f0c894fac193f50af990675012480c8677.tar.gz
go-5bf420f0c894fac193f50af990675012480c8677.zip
pidigits: Remove TODO, minor improvements
I tried adding a Scale method to big.Int and it didn't make any noticeable difference, so I'm removing my TODO. Also got rid of a few obvious allocations that I missed earlier for a modest improvement (~5%). R=golang-dev, gri CC=golang-dev https://golang.org/cl/2711043
-rw-r--r--test/bench/pidigits.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/bench/pidigits.go b/test/bench/pidigits.go
index 55da379438..e59312177f 100644
--- a/test/bench/pidigits.go
+++ b/test/bench/pidigits.go
@@ -49,6 +49,7 @@ var silent = flag.Bool("s", false, "don't print result")
var (
tmp1 = big.NewInt(0)
tmp2 = big.NewInt(0)
+ tmp3 = big.NewInt(0)
y2 = big.NewInt(0)
bigk = big.NewInt(0)
numer = big.NewInt(1)
@@ -80,7 +81,6 @@ func extract_digit() int64 {
}
func next_term(k int64) {
- // TODO(eds) If big.Int ever gets a Scale method, y2 and bigk could be int64
y2.SetInt64(k*2 + 1)
bigk.SetInt64(k)
@@ -92,8 +92,8 @@ func next_term(k int64) {
}
func eliminate_digit(d int64) {
- tmp := big.NewInt(0).Set(denom)
- accum.Sub(accum, tmp.Mul(tmp, big.NewInt(d)))
+ tmp3.SetInt64(d)
+ accum.Sub(accum, tmp3.Mul(denom, tmp3))
accum.Mul(accum, ten)
numer.Mul(numer, ten)
}