From 7d57599b9d9c5fb48ea733596cbb812d7f84a8d6 Mon Sep 17 00:00:00 2001 From: Veselkov Konstantin Date: Sat, 15 Sep 2018 21:23:36 +0400 Subject: fixed warnings gocritic 3.3 (#192) --- util.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'util.go') diff --git a/util.go b/util.go index 746bca6..0e89bbe 100644 --- a/util.go +++ b/util.go @@ -114,7 +114,8 @@ func utf8toutf16(s string) string { for i < nb { c1 := byte(s[i]) i++ - if c1 >= 224 { + switch { + case c1 >= 224: // 3-byte character c2 := byte(s[i]) i++ @@ -122,13 +123,13 @@ func utf8toutf16(s string) string { i++ res = append(res, ((c1&0x0F)<<4)+((c2&0x3C)>>2), ((c2&0x03)<<6)+(c3&0x3F)) - } else if c1 >= 192 { + case c1 >= 192: // 2-byte character c2 := byte(s[i]) i++ res = append(res, ((c1 & 0x1C) >> 2), ((c1&0x03)<<6)+(c2&0x3F)) - } else { + default: // Single-byte character res = append(res, 0, c1) } -- cgit v1.2.1-24-ge1ad