From 37c9765ab4cab757fa6f8cd37dc0e6c71cf5256b Mon Sep 17 00:00:00 2001 From: p01 Date: Mon, 2 Jun 2014 12:14:53 +0200 Subject: [PATCH] Optimized Lexer_getObj 2x faster --- src/core/parser.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/parser.js b/src/core/parser.js index b5a4b791a..a4dc3e4f0 100644 --- a/src/core/parser.js +++ b/src/core/parser.js @@ -755,19 +755,19 @@ var Lexer = (function LexerClosure() { // command var str = String.fromCharCode(ch); var knownCommands = this.knownCommands; - var knownCommandFound = knownCommands && (str in knownCommands); + var knownCommandFound = knownCommands && knownCommands[str] !== undefined; while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) { // stop if known command is found and next character does not make // the str a command var possibleCommand = str + String.fromCharCode(ch); - if (knownCommandFound && !(possibleCommand in knownCommands)) { + if (knownCommandFound && knownCommands[possibleCommand] === undefined) { break; } if (str.length === 128) { error('Command token too long: ' + str.length); } str = possibleCommand; - knownCommandFound = knownCommands && (str in knownCommands); + knownCommandFound = knownCommands && knownCommands[str] !== undefined; } if (str === 'true') { return true;