Skip to content

Commit

Permalink
Add lowerhex
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyunhao116 authored and kirillDanshin committed Sep 20, 2019
1 parent 79bd450 commit be93fbd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
3 changes: 2 additions & 1 deletion bytesconv.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func writeHexInt(w *bufio.Writer, n int) error {
buf := v.([]byte)
i := len(buf) - 1
for {
buf[i] = upperhex[n&0xf]
buf[i] = lowerhex[n&0xf]
n >>= 4
if n == 0 {
break
Expand Down Expand Up @@ -327,6 +327,7 @@ var hex2intTable = func() []byte {
const (
toLower = 'a' - 'A'
upperhex = "0123456789ABCDEF"
lowerhex = "0123456789abcdef"
)

var toLowerTable = func() [256]byte {
Expand Down
12 changes: 0 additions & 12 deletions bytesconv_timing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,6 @@ func BenchmarkAppendIPv4(b *testing.B) {
})
}

func BenchmarkInt2HexByte(b *testing.B) {
buf := []int{1, 0xf, 2, 0xd, 3, 0xe, 4, 0xa, 5, 0xb, 6, 0xc, 7, 0xf, 0, 0xf, 6, 0xd, 9, 8, 4, 0x5}
b.RunParallel(func(pb *testing.PB) {
var n int
for pb.Next() {
for _, n = range buf {
int2hexbyte(n)
}
}
})
}

func BenchmarkWriteHexInt(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
var w bytebufferpool.ByteBuffer
Expand Down

0 comments on commit be93fbd

Please sign in to comment.