-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using `Vec::remove(i)` causes the `n` tokens between position `i` and the end of the vector to be shifted, which is an `O(n)` operation. When done in a loop, as it is done in our `INSERT INTO ... VALUES` repeated list sanitisation, it makes the overall performance `O(n^2)`. To avoid using `Vec::remove`, implement a `Token::None` value that represents a "non-token", a gap to be ignored in the token list. Replace calls to `Vec::remove(i)` with replacing the token at position `i` with `Token::None`. Replace calls to `Vec::insert` for the same reason -- luckily, when we insert a token, it's a replacement for a different token, so it's possible to rewrite them in that manner. These are rarely done in a loop, though, so the impact on sanitisation performance is much more limited.
- Loading branch information
Showing
3 changed files
with
26 additions
and
8 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
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
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