-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve
BaseParser#unnormalize
(#194)
The current implementation of `#unnormalize` iterates over matched entity references that already has been substituted. With these changes we will reduce the number of redundant calls to `rv.gsub!`. * Reject filtered matches earlier in the loop * Improve `#unnormalize` by removing redundant calls to `rv.gsub!` * Improve `entity_expansion_limit` tests --- Example: ```ruby require "rexml/parsers/baseparser" entity_less_than = "<" entitiy_length = 100 filler_text = "A" filler_length = 100 feed = "#{entity_less_than * entitiy_length}#{filler_text * filler_length}" base_parser = REXML::Parsers::BaseParser.new("") base_parser.unnormalize(feed) # => "<" * 100 + "A" * 100 ``` Before this PR, the example above would require 100 iterations. After this PR, 1 iteration. --------- Co-authored-by: Sutou Kouhei <[email protected]>
- Loading branch information
Showing
3 changed files
with
54 additions
and
25 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