From 1bb8b1620082bc8d1eff22c52eb48204b1d4c943 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 27 Dec 2021 22:40:43 +0900 Subject: [PATCH] Optimize variables --- internal/encoder/decode_rune.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/encoder/decode_rune.go b/internal/encoder/decode_rune.go index 1fa1074..1087f0b 100644 --- a/internal/encoder/decode_rune.go +++ b/internal/encoder/decode_rune.go @@ -51,8 +51,7 @@ type acceptRange struct { hi uint8 // highest value for second byte. } -var ( - sep = [2]byte{226, 128} +const ( lineSep = byte(168) //'\u2028' paragraphSep = byte(169) //'\u2029' ) @@ -109,8 +108,9 @@ func decodeRuneInString(s string) (decodeRuneState, int) { return runeErrorState, 1 } if sz <= 3 { - if s[0] == sep[0] && s[1] == sep[1] { - switch s[2] { + // separator character prefixes: [2]byte{226, 128} + if s0 == 226 && s1 == 128 { + switch s2 { case lineSep: return lineSepState, 3 case paragraphSep: