Explorar el Código

Don't actually do stack push/pops where it was done for purity's sake. Instead reference the elements explicitly. This results in a minor speed win (~2% on FF)

tags/0.5.0-vsc
thegrandpoobah hace 15 años
padre
commit
b91a82f785
Se han modificado 1 ficheros con 5 adiciones y 9 borrados
  1. +5
    -9
      mustache.js

+ 5
- 9
mustache.js Ver fichero

@@ -344,18 +344,14 @@ var Mustache = function() {
var result = this.stateMachine.simpleKeyName.call(this, parserContext, contextStack); var result = this.stateMachine.simpleKeyName.call(this, parserContext, contextStack);
if (result==='closeMustache') { if (result==='closeMustache') {
var tagKey = parserContext.stack.pop();
var tag = parserContext.stack.pop();
var tagKey = parserContext.stack[parserContext.stack.length-1],
tag = parserContext.stack[parserContext.stack.length-2];
if (tag.tagType==='unescapedVariable' && tag.subtype==='tripleMustache') { if (tag.tagType==='unescapedVariable' && tag.subtype==='tripleMustache') {
parserContext.stack.push({tagType:'unescapedVariable'});
parserContext.stack.push(tagKey);
parserContext.stack[parserContext.stack.length-2] = {tagType:'unescapedVariable'};
return 'expectClosingMustache'; return 'expectClosingMustache';
} else { } else {
parserContext.stack.push(tag);
parserContext.stack.push(tagKey);
return 'closeMustache'; return 'closeMustache';
} }
} else if (result==='simpleKeyName') { } else if (result==='simpleKeyName') {
@@ -389,7 +385,7 @@ var Mustache = function() {
} else if (parserContext.token==='='){ } else if (parserContext.token==='='){
throw new ParserException('Syntax error in Set Delimiter tag'); throw new ParserException('Syntax error in Set Delimiter tag');
} else { } else {
parserContext.stack.push(parserContext.stack.pop() + parserContext.token);
parserContext.stack[parserContext.stack.length-1] += parserContext.token;
return 'setDelimiterStartOrWhitespace'; return 'setDelimiterStartOrWhitespace';
} }
@@ -411,7 +407,7 @@ var Mustache = function() {
} else if (this.isWhitespace(parserContext.token)) { } else if (this.isWhitespace(parserContext.token)) {
throw new ParserException('Syntax error in Set Delimiter tag'); throw new ParserException('Syntax error in Set Delimiter tag');
} else { } else {
parserContext.stack.push(parserContext.stack.pop() + parserContext.token);
parserContext.stack[parserContext.stack.length-1] += parserContext.token;
return 'setDelimiterEndOrEqualSign'; return 'setDelimiterEndOrEqualSign';
} }


Cargando…
Cancelar
Guardar