diff options
author | James Gregory <james@james.id.au> | 2013-08-01 11:32:57 -0700 |
---|---|---|
committer | James Gregory <james@james.id.au> | 2013-08-01 11:32:57 -0700 |
commit | 792959cea206b759a1402bb48d7797ebdee6c4ee (patch) | |
tree | 6c9a75e99971879460433c8cb05be795f30a3da6 /src/library.js | |
parent | 61526bc8b6eca8950e34616fc9cad2212c18abe6 (diff) |
Use switch statement for isspace implementation. Results in huge speed increase on Chrome Android at least, avoiding a hot path in common tasks like XML parsing, etc.
Diffstat (limited to 'src/library.js')
-rw-r--r-- | src/library.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/library.js b/src/library.js index f7c7a3ba..9feeac6d 100644 --- a/src/library.js +++ b/src/library.js @@ -4947,7 +4947,17 @@ LibraryManager.library = { (chr >= {{{ charCode('{') }}} && chr <= {{{ charCode('~') }}}); }, isspace: function(chr) { - return chr in { 32: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0 }; + switch(chr) { + case 32: + case 9: + case 10: + case 11: + case 12: + case 13: + return true; + default: + return false; + }; }, isblank: function(chr) { return chr == {{{ charCode(' ') }}} || chr == {{{ charCode('\t') }}}; |