Commit cdb8723
committed
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.1 parent b461323 commit cdb8723
1 file changed
+12
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
66 | 72 | | |
67 | 73 | | |
68 | 74 | | |
| |||
107 | 113 | | |
108 | 114 | | |
109 | 115 | | |
110 | | - | |
| 116 | + | |
111 | 117 | | |
112 | 118 | | |
113 | 119 | | |
| |||
134 | 140 | | |
135 | 141 | | |
136 | 142 | | |
137 | | - | |
| 143 | + | |
138 | 144 | | |
139 | 145 | | |
140 | 146 | | |
| |||
166 | 172 | | |
167 | 173 | | |
168 | 174 | | |
169 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
170 | 179 | | |
171 | 180 | | |
172 | 181 | | |
| |||
0 commit comments