-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change TrueType subsetter to avoid generating characters that need to…
… be escaped If text is output into a content stream, it needs to be serialized according to the PDF spec rules. For serializing strings HexaPDF has chosen the literal string syntax because the hexadecimal string syntax would need twice as many characters. For literal strings there are four characters -- \r, (, ), \ -- that need to be escaped. If any of theses characters appears in the string, String#gsub! has to actually do some work modifying the string. By making sure that the encoded text using a TrueType font doesn't contain those characters we avoid this work. This change saves about 31% of object allocations and about 5% runtime on the raw_text 10x TrueType benchmark.
- Loading branch information
Showing
1 changed file
with
12 additions
and
3 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
I'm wondering if there's a bug here. What happens if @last_id is 40 here? My take is that you'll enter this conditional block, update the @last_id to 41 and use that (which is also invalid!).
Perhaps, this instead?