From f91ec89f05ae4cbd86dc19c4228b5b603394f3c9 Mon Sep 17 00:00:00 2001 From: waddlesplash Date: Thu, 10 Oct 2013 19:10:35 -0400 Subject: [PATCH] Allow JIT optimization. Firefox speeds up a lot with this. --- sprites.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sprites.js b/sprites.js index 81307a9..a0241dc 100644 --- a/sprites.js +++ b/sprites.js @@ -582,9 +582,13 @@ function memcpyU8(source, destination, readloc, writeloc, writelength/*, thing*/ if(readloc == null) readloc = 0; if(writeloc == null) writeloc = 0; if(writelength == null) writelength = max(0, min(source.length, destination.length)); - while(writelength--) - // while(--writelength) - destination[writeloc++] = source[readloc++]; + + var lwritelength = writelength + 0; // Allow JIT integer optimization (Firefox needs this) + var lwriteloc = writeloc + 0; + var lreadloc = readloc + 0; + while(lwritelength--) + // while(--lwritelength) + destination[lwriteloc++] = source[lreadloc++]; } // Somewhat cross-platform way to make a canvas' 2d context not smooth pixels