This repository was archived by the owner on Jun 20, 2023. It is now read-only.
File tree 1 file changed +7
-8
lines changed
1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -37,22 +37,21 @@ func (b *Buzhash) NextBytes() ([]byte, error) {
37
37
return nil , b .err
38
38
}
39
39
40
- buf := b .buf
41
- n , err := io .ReadFull (b .r , buf [b .n :])
40
+ n , err := io .ReadFull (b .r , b .buf [b .n :])
42
41
if err != nil {
43
42
if err == io .ErrUnexpectedEOF || err == io .EOF {
44
43
if b .n + n < buzMin {
45
44
b .err = io .EOF
46
45
res := make ([]byte , b .n + n )
47
- copy (res , buf )
46
+ copy (res , b . buf )
48
47
49
48
pool .Put (b .buf )
50
49
b .buf = nil
51
50
return res , nil
52
51
}
53
52
} else {
54
53
b .err = err
55
- pool .Put (buf )
54
+ pool .Put (b . buf )
56
55
b .buf = nil
57
56
return nil , err
58
57
}
@@ -64,21 +63,21 @@ func (b *Buzhash) NextBytes() ([]byte, error) {
64
63
65
64
for ; i < buzMin ; i ++ {
66
65
state = bits .RotateLeft32 (state , 1 )
67
- state = state ^ bytehash [buf [i ]]
66
+ state = state ^ bytehash [b. buf [i ]]
68
67
}
69
68
70
- if b .n + n > len (buf ) {
69
+ if b .n + n > len (b . buf ) {
71
70
panic ("this is impossible, but gives +9 to performance" )
72
71
}
73
72
74
73
for ; state & buzMask != 0 && i < b .n + n ; i ++ {
75
- state = bits .RotateLeft32 (state , 1 ) ^ bytehash [buf [i - 32 ]] ^ bytehash [buf [i ]]
74
+ state = bits .RotateLeft32 (state , 1 ) ^ bytehash [b . buf [i - 32 ]] ^ bytehash [b. buf [i ]]
76
75
}
77
76
78
77
res := make ([]byte , i )
79
78
copy (res , b .buf )
80
79
81
- b .n = copy (b .buf , buf [i :b .n + n ])
80
+ b .n = copy (b .buf , b . buf [i :b .n + n ])
82
81
83
82
return res , nil
84
83
}
You can’t perform that action at this time.
0 commit comments