-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't set array capacity in
repeat-expr
(costly in invalid files)
Cc @armijnhemel Although the pre-allocation of the array can speed up parsing of the repeated field by a few percent (assuming that the parsed file is completely valid), it poses a serious issue for invalid files where some random group of high bytes has been interpreted as the number of entries. That will allocate a ridiculously large array (for example 2 million entries or more), which is costly and unnecessary (because the parsing is likely to fail much sooner than after parsing all 2 million records). This change puts the `repeat: expr` in line with `eos` and `until`, so it was suddenly possible to refactor the piece of code taking care of creating the array to a common place - the `condRepeatExprHeader()` method, which is called from all types of repeats.
- Loading branch information
1 parent
5773e73
commit f5fe28e
Showing
14 changed files
with
145 additions
and
239 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
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
Oops, something went wrong.