From 8ef0b630299b0ba758ec3115f016fbf4c2a7c622 Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Fri, 2 Mar 2012 21:28:21 +0100 Subject: [PATCH] A little faster renderLine --- .../javascripts/player/terminal_view.js.coffee | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/player/terminal_view.js.coffee b/app/assets/javascripts/player/terminal_view.js.coffee index bf4dfe5..09818ea 100644 --- a/app/assets/javascripts/player/terminal_view.js.coffee +++ b/app/assets/javascripts/player/terminal_view.js.coffee @@ -43,7 +43,7 @@ class AsciiIo.TerminalView extends Backbone.View @$el.css(width: width + 'px', height: height + 'px') renderLine: (n, data, cursorX) -> - html = '' + html = [] prevBrush = undefined for i in [0...@cols] @@ -56,19 +56,19 @@ class AsciiIo.TerminalView extends Backbone.View if brush != prevBrush or i is cursorX or i is (cursorX + 1) if prevBrush - html += '' + html.push '' - html += @spanFromBrush(brush, i is cursorX) + html.push @spanFromBrush(brush, i is cursorX) prevBrush = brush - html += char + html.push char else - html += ' ' + html.push ' ' - html += '' if prevBrush + html.push '' if prevBrush - @$el.find(".line:eq(" + n + ")").html html + @$el.find(".line:eq(" + n + ")").html html.join('') spanFromBrush: (brush, hasCursor) -> key = "#{brush.hash()}_#{hasCursor}"