mirror of
https://github.com/golang/go
synced 2024-11-12 09:50:21 -07:00
- fix performance bug (makeN always allocated a new vector)
- removed defs.go (moved declarations into arith.go where they belong) R=r DELTA=40 (16 added, 20 deleted, 4 changed) OCL=33464 CL=33464
This commit is contained in:
parent
ac5093fc22
commit
116b52d276
@ -6,7 +6,6 @@ include $(GOROOT)/src/Make.$(GOARCH)
|
||||
|
||||
TARG=big
|
||||
GOFILES=\
|
||||
defs.go\
|
||||
arith.go\
|
||||
big.go\
|
||||
nat.go\
|
||||
|
@ -10,6 +10,18 @@ package big
|
||||
|
||||
import "unsafe"
|
||||
|
||||
type Word uintptr
|
||||
|
||||
const (
|
||||
_S = uintptr(unsafe.Sizeof(Word)); // TODO(gri) should Sizeof return a uintptr?
|
||||
_W = _S*8;
|
||||
_B = 1<<_W;
|
||||
_M = _B-1;
|
||||
_W2 = _W/2;
|
||||
_B2 = 1<<_W2;
|
||||
_M2 = _B2-1;
|
||||
)
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Elementary operations on words
|
||||
|
@ -1,19 +0,0 @@
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package big
|
||||
|
||||
import "unsafe"
|
||||
|
||||
type Word uintptr
|
||||
|
||||
const (
|
||||
_S = uintptr(unsafe.Sizeof(Word)); // TODO(gri) should Sizeof return a uintptr?
|
||||
_W = _S*8;
|
||||
_B = 1<<_W;
|
||||
_M = _B-1;
|
||||
_W2 = _W/2;
|
||||
_B2 = 1<<_W2;
|
||||
_M2 = _B2-1;
|
||||
)
|
@ -36,10 +36,14 @@ func normN(z []Word) []Word {
|
||||
func makeN(z []Word, m int, clear bool) []Word {
|
||||
if len(z) > m {
|
||||
z = z[0 : m]; // reuse z - has at least one extra word for a carry, if any
|
||||
for i := range z {
|
||||
z[i] = 0;
|
||||
if clear {
|
||||
for i := range z {
|
||||
z[i] = 0;
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
c := 4; // minimum capacity
|
||||
if m > c {
|
||||
c = m;
|
||||
|
Loading…
Reference in New Issue
Block a user