codeforamerica/trails-mobile — pull request #131 by anselmbradford (2014-05-20 04:08:01+00:00)
Title: Performance updates

Performs several performance optimizations:
- Removes redundant call to search function at app load.
- Keeps simplified structure of trail info view animation, but swaps out `translate3d` in place of `top` as was originally used in the animation to make use of hardware acceleration, per comments in #114. If this continues to have performance issues, adding `translate3d(0, 0, 0)` to all child nodes of `#trail-view` should be investigated.
- Adds JSHint task and performs JS code quality audit and cleanup.
- Combines creation of map markers and adding of click event handler to trailheadmarkers in a single function. These had been two separate functions that both looped through the trailheadmarkers at app load and were then never called again, so combining these eliminates an expensive loop that is only performed once now, instead of twice.
- Converts filters to use a bitmap instead of a list of boolean values, this allows all filter settings to be stored in one integer. _However, it is of note that this does require bitwise operations, which are very fast but make the code a bit more obfuscated around the filters because of their unusual appearance._ On first click of a filter bitmap values are calculated and stored for trail segments, which means subsequent clicks no longer unnecessarily re-calculate the filter states for segments. This means adding additional filters into a search doesn't give an additional performance hit for each filter added. Additionally, the loop to check trail filter states can check the single bitmap instead of looping through each filter, thus allowing an extra loop to be eliminated. Clicking the filters remains a costly operation, but this update substantially increased the speed by an order of 200-400%, which should help with #113.

@alanjosephwilliams ready for review and merge. Please check on a device for https://github.com/codeforamerica/trails-mobile/issues/129 resolution.