forked from lddubeau/saxes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: minimine concatenation by adding the capability to unget codes
There was a recurring pattern in the code whereby a buffer (e.g. ``this.name``) would be filled first by adding a single character to it, and then by concatenating a slice from the current chunk. Internally, Node would create a cons string from the two parts, which would then be eventually concatenated behind the scenes to a final string. The new code adds ``this.prevI`` which allows backing up the reading of codes ("ungetting" codes). So in the scenario described above, instead of filling the buffer with a single character concatenated with a slice, the buffer is filled with a slice that begins one character earlier than it would otherwise have. This skips the creation of a cons string and the concatenation behind the scenes. It also simplifies a few other pieces of code that need the index of the code just read from the chunk.
- Loading branch information
Showing
1 changed file
with
34 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters