Skip to content

Commit

Permalink
Split into two functions for the optimization to happen
Browse files Browse the repository at this point in the history
  • Loading branch information
NightRa committed Sep 13, 2016
1 parent db04484 commit 5095215
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/jison.js
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,12 @@ function parseError (str, hash) {
parser.parseError = lrGeneratorMixin.parseError = parseError;

parser.parse = function parse (input) {
var args = new Array(arguments.length - 1);
for (var i = 0; i < arguments.length - 1; i++) {
args[i] = arguments[i + 1];
}

var parseInner = function parseInner (input, args) {
var self = this,
stack = [0],
tstack = [], // token stack
Expand All @@ -1381,11 +1387,6 @@ parser.parse = function parse (input) {
TERROR = 2,
EOF = 1;

var args = new Array(arguments.length - 1);
for (var i = 0; i < arguments.length - 1; i++) {
args[i] = arguments[i + 1];
}

//this.reductionCount = this.shiftCount = 0;

var lexer = Object.create(this.lexer);
Expand Down Expand Up @@ -1607,7 +1608,13 @@ _handle_error:
}

return true;
};
}

return parseInner.bind(this)(input, args);

}



parser.init = function parser_init (dict) {
this.table = dict.table;
Expand Down

0 comments on commit 5095215

Please sign in to comment.