Repository navigation
Conversation
The case of `ref.size == idx` is removed because after the introduction of addToken insertToken is not used at the end. Otherwise it should just call addToken.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #967 +/- ##
==========================================
+ Coverage 80.65% 80.77% +0.11%
==========================================
Files 22 22
Lines 6845 6839 -6
==========================================
+ Hits 5521 5524 +3
+ Misses 905 898 -7
+ Partials 419 417 -2 🚀 New features to boost your workflow:
|
757eb17 to
366bf7d
Compare
chiliec
left a comment
There was a problem hiding this comment.
Reviewed and tested locally: go test ./... passes, and I diffed decode results and the bytes passed to CustomUnmarshaler on master vs this branch for implicit-null/tag-default insertion at EOF and comment-heavy inputs — identical. With a custom unmarshaler it's 4.5 ms / 21 ms for 1k / 4k items (master: 473 ms / 9.3 s), and it scales linearly, unlike my #966. One note: insertToken no longer handles idx == size; nothing calls it that way today, but a guard that falls back to addToken would make that explicit. LGTM — I've closed #966 in favour of this.
366bf7d to
4281383
Compare
Fixes goccy#965 quadratic blow up in scanning the whole document just to count newlines in the comments before the token.
4281383 to
c90d5c3
Compare
| for prev := tk.Prev; prev != nil && prev.Type == token.CommentType; prev = prev.Prev { | ||
| newlines += strings.Count(normalizeNewLineChars(prev.Origin), "\n") | ||
| } | ||
| return strings.Repeat("\n", newlines) + tk.Origin |
There was a problem hiding this comment.
I have checked that when newlines is 0 this is free (tk.Origin is returned without copying) and removed the special case (if newlines == 0 return tk.Origin).
| ref.tokens = append(ref.tokens, tk) | ||
| ref.size = len(ref.tokens) | ||
| return | ||
| } |
There was a problem hiding this comment.
The case of ref.size == idx is removed because after the introduction of addToken
insertToken is not used at the end. Otherwise it should just call addToken.
Fixes #965
Closes #714 as obsolete
Please see individual commits.
This is a speed up, all tests pass.