@@ -308,13 +308,13 @@ func Test_validWireCloseCode(t *testing.T) {
308308 }
309309}
310310
311- func Test_xor (t * testing.T ) {
311+ func Test_mask (t * testing.T ) {
312312 t .Parallel ()
313313
314314 key := []byte {0xa , 0xb , 0xc , 0xff }
315315 key32 := binary .LittleEndian .Uint32 (key )
316316 p := []byte {0xa , 0xb , 0xc , 0xf2 , 0xc }
317- gotKey32 := fastXOR (key32 , p )
317+ gotKey32 := mask (key32 , p )
318318
319319 if exp := []byte {0 , 0 , 0 , 0x0d , 0x6 }; ! cmp .Equal (exp , p ) {
320320 t .Fatalf ("unexpected mask: %v" , cmp .Diff (exp , p ))
@@ -325,15 +325,15 @@ func Test_xor(t *testing.T) {
325325 }
326326}
327327
328- func basixXOR (maskKey [4 ]byte , pos int , b []byte ) int {
328+ func basixMask (maskKey [4 ]byte , pos int , b []byte ) int {
329329 for i := range b {
330330 b [i ] ^= maskKey [pos & 3 ]
331331 pos ++
332332 }
333333 return pos & 3
334334}
335335
336- func BenchmarkXOR (b * testing.B ) {
336+ func Benchmark_mask (b * testing.B ) {
337337 sizes := []int {
338338 2 ,
339339 3 ,
@@ -355,18 +355,18 @@ func BenchmarkXOR(b *testing.B) {
355355 name : "basic" ,
356356 fn : func (b * testing.B , key [4 ]byte , p []byte ) {
357357 for i := 0 ; i < b .N ; i ++ {
358- basixXOR (key , 0 , p )
358+ basixMask (key , 0 , p )
359359 }
360360 },
361361 },
362362 {
363363 name : "fast" ,
364364 fn : func (b * testing.B , key [4 ]byte , p []byte ) {
365- key32 := binary .BigEndian .Uint32 (key [:])
365+ key32 := binary .LittleEndian .Uint32 (key [:])
366366 b .ResetTimer ()
367367
368368 for i := 0 ; i < b .N ; i ++ {
369- fastXOR (key32 , p )
369+ mask (key32 , p )
370370 }
371371 },
372372 },
@@ -384,7 +384,6 @@ func BenchmarkXOR(b *testing.B) {
384384 b .Run (strconv .Itoa (size ), func (b * testing.B ) {
385385 for _ , fn := range fns {
386386 b .Run (fn .name , func (b * testing.B ) {
387- b .ReportAllocs ()
388387 b .SetBytes (int64 (size ))
389388
390389 fn .fn (b , key , p )
0 commit comments