diff options
author | Adam Scarr <adam@vektah.net> | 2017-08-13 21:20:41 +1000 |
---|---|---|
committer | Adam Scarr <adam@vektah.net> | 2017-08-13 21:20:41 +1000 |
commit | 139e7606f4ab68b469438956c378745f51f7b65b (patch) | |
tree | 2eaa9cb87e008ecaffefc01c5da933f1ea9852dd /state.go | |
parent | 1c37779bd46d988c9e7b4bdb846b9daa89856b7c (diff) |
Update benchmarks
Diffstat (limited to 'state.go')
-rw-r--r-- | state.go | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -1,6 +1,7 @@ package goparsify import ( + "strconv" "unicode" "unicode/utf8" ) @@ -72,11 +73,14 @@ func (s *State) Preview(x int) string { if s.Pos >= len(s.Input) { return "" } - if len(s.Input)-s.Pos >= x { - return s.Input[s.Pos : s.Pos+x] + + quoted := strconv.Quote(s.Get()) + quoted = quoted[1 : len(quoted)-1] + if len(quoted) >= x { + return quoted[0:x] } - return s.Input[s.Pos:] + return quoted } // ErrorHere raises an error at the current position. |