Ensure the loop counter is not interpreted as a double.

This patch improves pure JavaScript performances by 30% by removing double computations from Type1Parser_extractFontProgram. When parseInt is fed with non numerical values, it returns a NaN which flows into the loop counter which cause every operation to be computed as a double and every index to be trunctated as an int before reading a character.  This patch force the NaN value to be coerce as an integer by using a bitwise-or operation with zero.
This commit is contained in:
Nicolas Pierron 2012-11-15 23:46:43 -08:00
parent 7419c75177
commit f5e8838bb0

View File

@ -4755,7 +4755,9 @@ var Type1Parser = function type1Parser() {
i += length;
token = '';
} else if (isSeparator(c)) {
length = parseInt(token, 10);
// Use '| 0' to prevent setting a double into length such as the double
// does not flow into the loop variable.
length = parseInt(token, 10) | 0;
token = '';
} else {
token += c;