diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-01-03 17:35:59 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-01-03 17:35:59 -0800 |
commit | c0beb1cff3a831039884f90ef2978e2345610992 (patch) | |
tree | 010ce29ad2fdf19e7c8cefb3e88f31c643f862e9 | |
parent | 15253e694911f203c5ecd4f7577a42289554f79e (diff) |
optimize main loop in SDL_UnlockSurface to avoid a branch
-rw-r--r-- | src/library_sdl.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js index cc969c27..fc38dd1c 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -1078,9 +1078,15 @@ var LibrarySDL = { } else { var data32 = new Uint32Array(data.buffer); num = data32.length; - while (dst < num) { - // HEAP32[src++] is an optimization. Instead, we could do {{{ makeGetValue('buffer', 'dst', 'i32') }}}; - data32[dst++] = HEAP32[src++] | (isScreen ? 0xff000000 : 0); + if (isScreen) { + while (dst < num) { + // HEAP32[src++] is an optimization. Instead, we could do {{{ makeGetValue('buffer', 'dst', 'i32') }}}; + data32[dst++] = HEAP32[src++] | 0xff000000; + } + } else { + while (dst < num) { + data32[dst++] = HEAP32[src++]; + } } } #else |