Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The old max_line_len code fell into a surprising slowdown where repeatedly inserting chars in the middle of a string falls into O(n^2) behavior. Surprising because V8 already implements advanced data structures for string slicing and joining (`SlicedString` and `ConsString`). It seems like this should be easily handled by the two. Anyways, we avoid this by slowing building a committed string (which is unlikely to be changed). Whenever we insert, we commit the left hand side, and can avoid slicing it in the future. In testing a 5mb file (done by repeating a program several times), I dropped the simple parse+output case from 5min to 5sec.
- Loading branch information
1 parent
8539751
commit a966e74
Showing
1 changed file
with
61 additions
and
19 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