From f3fce151015ec1388b515b6de7bd852b8faef092 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Tue, 5 Jul 2011 09:45:14 +0200 Subject: [PATCH] [ "", "" ].join( '' ) is faster than "" + "" http://code.google.com/p/jslibs/wiki/JavascriptTips#Multiple_string_concatenation --- star.js/js/star.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/star.js/js/star.js b/star.js/js/star.js index f19d7d5..2e468f3 100644 --- a/star.js/js/star.js +++ b/star.js/js/star.js @@ -82,7 +82,7 @@ function get_cell( state, x, y ) { function set_cell( state, x, y, value ) { p = x + ( y * LEVEL_WIDTH ); - state.board = state.board.substring( 0, p ) + value + state.board.substring( p+1, state.board.length ); + state.board = [ state.board.substring( 0, p ), value, state.board.substring( p+1, state.board.length ) ].join( '' ); return state; } @@ -99,11 +99,11 @@ function format_level( state ) { dl = ""; for ( i = 0 ; i < LEVEL_HEIGHT * LEVEL_WIDTH ; i++ ) { c = state.board[ i ]; - classes = "starcell " + css_classes[ c ]; + classes = [ "starcell ", css_classes[ c ] ].join( '' ); if ( state.moving == c) { - classes = classes + " selected "; + classes = [ classes, " selected " ].join( '' ); } - dl = dl + "" + c + ""; + dl = [ dl, "", c, ""].join( '' ); } return dl; }