Skip to content

Commit

Permalink
Only iterate over tokens once
Browse files Browse the repository at this point in the history
  • Loading branch information
zertosh committed Mar 25, 2017
1 parent 06c3a31 commit 539af05
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions babylon-to-espree/toTokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ var toToken = require("./toToken");
module.exports = function (tokens, tt, code) {
// transform tokens to type "Template"
convertTemplateType(tokens, tt);
var transformedTokens = tokens.filter((token) => {
return token.type !== "CommentLine" && token.type !== "CommentBlock";
});

for (var i = 0, l = transformedTokens.length; i < l; i++) {
transformedTokens[i] = toToken(transformedTokens[i], tt, code);
var transformedTokens = [];
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
if (token.type !== "CommentLine" && token.type !== "CommentBlock") {
transformedTokens.push(toToken(token, tt, code));
}
}

return transformedTokens;
Expand Down

0 comments on commit 539af05

Please sign in to comment.