Skip to content

Commit 2be64d3

Browse files
committed
unicode/utf8: use binary literals
We were using hex literals and had the binary literal in a comment. When I was working with this code, I always referred to the comment. That's an indicator that we should just use the binary literal directly. Updates #19308 Change-Id: I2279cb8efb4ae5f2e1558c15979058ab09eb4f6f Reviewed-on: https://go-review.googlesource.com/c/go/+/173663 Run-TryBot: Josh Bleecher Snyder <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 57076b8 commit 2be64d3

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/unicode/utf8/utf8.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ const (
2525
)
2626

2727
const (
28-
t1 = 0x00 // 0000 0000
29-
tx = 0x80 // 1000 0000
30-
t2 = 0xC0 // 1100 0000
31-
t3 = 0xE0 // 1110 0000
32-
t4 = 0xF0 // 1111 0000
33-
t5 = 0xF8 // 1111 1000
28+
t1 = 0b00000000
29+
tx = 0b10000000
30+
t2 = 0b11000000
31+
t3 = 0b11100000
32+
t4 = 0b11110000
33+
t5 = 0b11111000
3434

35-
maskx = 0x3F // 0011 1111
36-
mask2 = 0x1F // 0001 1111
37-
mask3 = 0x0F // 0000 1111
38-
mask4 = 0x07 // 0000 0111
35+
maskx = 0b00111111
36+
mask2 = 0b00011111
37+
mask3 = 0b00001111
38+
mask4 = 0b00000111
3939

4040
rune1Max = 1<<7 - 1
4141
rune2Max = 1<<11 - 1
4242
rune3Max = 1<<16 - 1
4343

4444
// The default lowest and highest continuation byte.
45-
locb = 0x80 // 1000 0000
46-
hicb = 0xBF // 1011 1111
45+
locb = 0b10000000
46+
hicb = 0b10111111
4747

4848
// These names of these constants are chosen to give nice alignment in the
4949
// table below. The first nibble is an index into acceptRanges or F for

0 commit comments

Comments
 (0)