Просмотр исходного кода

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 15 лет назад
Родитель
Сommit
b91a82f785
1 измененных файлов: 5 добавлений и 9 удалений
  1. +5
    -9
      mustache.js

+ 5
- 9
mustache.js Просмотреть файл

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


Загрузка…
Отмена
Сохранить