mirror of
https://github.com/gwenhael-le-moine/c-urs_-toil-s.git
synced 2024-12-26 09:58:48 +01:00
[ "", "" ].join( '' ) is faster than "" + ""
http://code.google.com/p/jslibs/wiki/JavascriptTips#Multiple_string_concatenation
This commit is contained in:
parent
f775d6ec8e
commit
f3fce15101
1 changed files with 4 additions and 4 deletions
|
@ -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 + "<span class=\"" + classes + "\">" + c + "</span>";
|
||||
dl = [ dl, "<span class=\"", classes, "\">", c, "</span>"].join( '' );
|
||||
}
|
||||
return dl;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue