From: Josh Bleecher Snyder Date: Wed, 24 Apr 2019 22:41:26 +0000 (-0700) Subject: unicode/utf8: use binary literals X-Git-Tag: go1.13beta1~562 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2be64d36456d6e2ad14476b6d09b9fc4e2ac591e;p=gostls13.git 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 TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/unicode/utf8/utf8.go b/src/unicode/utf8/utf8.go index b351cc351f..2d4a486256 100644 --- a/src/unicode/utf8/utf8.go +++ b/src/unicode/utf8/utf8.go @@ -25,25 +25,25 @@ const ( ) const ( - t1 = 0x00 // 0000 0000 - tx = 0x80 // 1000 0000 - t2 = 0xC0 // 1100 0000 - t3 = 0xE0 // 1110 0000 - t4 = 0xF0 // 1111 0000 - t5 = 0xF8 // 1111 1000 + t1 = 0b00000000 + tx = 0b10000000 + t2 = 0b11000000 + t3 = 0b11100000 + t4 = 0b11110000 + t5 = 0b11111000 - maskx = 0x3F // 0011 1111 - mask2 = 0x1F // 0001 1111 - mask3 = 0x0F // 0000 1111 - mask4 = 0x07 // 0000 0111 + maskx = 0b00111111 + mask2 = 0b00011111 + mask3 = 0b00001111 + mask4 = 0b00000111 rune1Max = 1<<7 - 1 rune2Max = 1<<11 - 1 rune3Max = 1<<16 - 1 // The default lowest and highest continuation byte. - locb = 0x80 // 1000 0000 - hicb = 0xBF // 1011 1111 + locb = 0b10000000 + hicb = 0b10111111 // These names of these constants are chosen to give nice alignment in the // table below. The first nibble is an index into acceptRanges or F for