aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-11-01 16:38:40 +0100
committerThomas Voss <mail@thomasvoss.com> 2023-11-01 16:38:40 +0100
commiteced3e62c922ee121429759eaa5d4956eb17085d (patch)
treebd80c8e02c2e58db71bfc955e0fbb5e03109ba77
parentff9d73c1ff87bd6c54b0d306a8ad08ee653c9155 (diff)
Minor refactor
-rw-r--r--parser/reader.go6
1 files changed, 3 insertions, 3 deletions
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.