@@ -308,13 +308,13 @@ func Test_validWireCloseCode(t *testing.T) {
308
308
}
309
309
}
310
310
311
- func Test_xor (t * testing.T ) {
311
+ func Test_mask (t * testing.T ) {
312
312
t .Parallel ()
313
313
314
314
key := []byte {0xa ,0xb ,0xc ,0xff }
315
315
key32 := binary .LittleEndian .Uint32 (key )
316
316
p := []byte {0xa ,0xb ,0xc ,0xf2 ,0xc }
317
- gotKey32 := fastXOR (key32 ,p )
317
+ gotKey32 := mask (key32 ,p )
318
318
319
319
if exp := []byte {0 ,0 ,0 ,0x0d ,0x6 };! cmp .Equal (exp ,p ) {
320
320
t .Fatalf ("unexpected mask: %v" ,cmp .Diff (exp ,p ))
@@ -325,15 +325,15 @@ func Test_xor(t *testing.T) {
325
325
}
326
326
}
327
327
328
- func basixXOR (maskKey [4 ]byte ,pos int ,b []byte )int {
328
+ func basixMask (maskKey [4 ]byte ,pos int ,b []byte )int {
329
329
for i := range b {
330
330
b [i ]^= maskKey [pos & 3 ]
331
331
pos ++
332
332
}
333
333
return pos & 3
334
334
}
335
335
336
- func BenchmarkXOR (b * testing.B ) {
336
+ func Benchmark_mask (b * testing.B ) {
337
337
sizes := []int {
338
338
2 ,
339
339
3 ,
@@ -355,18 +355,18 @@ func BenchmarkXOR(b *testing.B) {
355
355
name :"basic" ,
356
356
fn :func (b * testing.B ,key [4 ]byte ,p []byte ) {
357
357
for i := 0 ;i < b .N ;i ++ {
358
- basixXOR (key ,0 ,p )
358
+ basixMask (key ,0 ,p )
359
359
}
360
360
},
361
361
},
362
362
{
363
363
name :"fast" ,
364
364
fn :func (b * testing.B ,key [4 ]byte ,p []byte ) {
365
- key32 := binary .BigEndian .Uint32 (key [:])
365
+ key32 := binary .LittleEndian .Uint32 (key [:])
366
366
b .ResetTimer ()
367
367
368
368
for i := 0 ;i < b .N ;i ++ {
369
- fastXOR (key32 ,p )
369
+ mask (key32 ,p )
370
370
}
371
371
},
372
372
},
@@ -384,7 +384,6 @@ func BenchmarkXOR(b *testing.B) {
384
384
b .Run (strconv .Itoa (size ),func (b * testing.B ) {
385
385
for _ ,fn := range fns {
386
386
b .Run (fn .name ,func (b * testing.B ) {
387
- b .ReportAllocs ()
388
387
b .SetBytes (int64 (size ))
389
388
390
389
fn .fn (b ,key ,p )