From 0ad26c337a35cccf7f645ae05e71aab5841f9fbc Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 19 May 2014 22:20:57 -0600 Subject: [PATCH] Don't use _.pluck when building TokenizedLines --- src/tokenized-line.coffee | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/tokenized-line.coffee b/src/tokenized-line.coffee index 1bbec7972..c59faea7e 100644 --- a/src/tokenized-line.coffee +++ b/src/tokenized-line.coffee @@ -7,11 +7,22 @@ class TokenizedLine constructor: ({tokens, @lineEnding, @ruleStack, @startBufferColumn, @fold, @tabLength, @indentLevel}) -> @tokens = @breakOutAtomicTokens(tokens) @startBufferColumn ?= 0 - @text = _.pluck(@tokens, 'value').join('') - @bufferDelta = _.sum(_.pluck(@tokens, 'bufferDelta')) + @text = @buildText() + @bufferDelta = @buildBufferDelta() + @id = idCounter++ @markLeadingAndTrailingWhitespaceTokens() + buildText: -> + text = "" + text += token.value for token in @tokens + text + + buildBufferDelta: -> + delta = 0 + delta += token.bufferDelta for token in @tokens + delta + copy: -> new TokenizedLine({@tokens, @lineEnding, @ruleStack, @startBufferColumn, @fold})