From eced3e62c922ee121429759eaa5d4956eb17085d Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 1 Nov 2023 16:38:40 +0100 Subject: Minor refactor --- parser/reader.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'parser/reader.go') diff --git a/parser/reader.go b/parser/reader.go index 28cbe3d..d9a1712 100644 --- a/parser/reader.go +++ b/parser/reader.go @@ -35,15 +35,15 @@ type reader struct { // parser forwards. func (reader *reader) peekRune() (rune, error) { bytes, _ := reader.r.Peek(4) - r, size := utf8.DecodeRune(bytes) - switch { + switch r, size := utf8.DecodeRune(bytes); { case r == utf8.RuneError && size == 0: return 0, io.EOF case r == utf8.RuneError && size == 1: return 0, errors.New("Tried to decode malformed UTF-8") + default: + return r, nil } - return r, nil } // unreadRune moves the parser one rune back, allowing for basic backtracking. -- cgit v1.2.3