01org/webapps-annex — pull request #6 by msridhar (2014-10-17 22:34:27+00:00)
Title: Optimizations

This PR contains two optimizations:

1. Change for-in loops over arrays to standard for loops. The for-in loops prevented the V8 JIT from optimizing the corresponding functions, and I imagine they could negatively affect other JITs as well.

2. Move the constant `mtable` object out of the `getValue` function, so it does not get repeatedly allocated.

On Chrome running on my 2.4GHz Core i7, I see the following performance improvement for computing the fourth computer move in a game.

Before changes: ~90ms
With change 1: ~35ms
With changes 1 and 2: ~23ms

90ms isn't a huge deal, but on less powerful hardware (like a mobile device), this optimization could lead to a perceptible performance improvement.