File tree 1 file changed +21
-5
lines changed
1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -61,17 +61,33 @@ func (b *Buzhash) NextBytes() ([]byte, error) {
61
61
62
62
var state uint32 = 0
63
63
64
+ if buzMin > len (b .buf ) {
65
+ panic ("this is impossible" )
66
+ }
67
+
64
68
for ; i < buzMin ; i ++ {
65
69
state = bits .RotateLeft32 (state , 1 )
66
70
state = state ^ bytehash [b.buf [i ]]
67
71
}
68
72
69
- if b .n + n > len (b .buf ) {
70
- panic ("this is impossible, but gives +9 to performance" )
71
- }
73
+ {
74
+ max := b .n + n - 32 - 1
72
75
73
- for ; state & buzMask != 0 && i < b .n + n ; i ++ {
74
- state = bits .RotateLeft32 (state , 1 ) ^ bytehash [b .buf [i - 32 ]] ^ bytehash [b.buf [i ]]
76
+ buf := b .buf
77
+ bufshf := b .buf [32 :]
78
+ i = buzMin - 32
79
+ _ = buf [max ]
80
+ _ = bufshf [max ]
81
+
82
+ for ; i <= max ; i ++ {
83
+ if state & buzMask == 0 {
84
+ break
85
+ }
86
+ state = bits .RotateLeft32 (state , 1 ) ^
87
+ bytehash [buf [i ]] ^
88
+ bytehash [bufshf [i ]]
89
+ }
90
+ i += 32
75
91
}
76
92
77
93
res := make ([]byte , i )
You can’t perform that action at this time.
0 commit comments