Provide more flexible caching for AAST
Summary:
- Provide buildSelectCache() to improve the performance of multiple selectDescendandsOfType() calls.
- Provide selectTokensOfType() as a performant accessor for some token selection.
- Provide buildTokenCache() to improve the performance of multiple selectTokensOfType() calls.
- Memoize and microoptimize some other hot paths.
Test Plan: XHPASTLinter runs correctly but ~5x faster on the unit test dataset (see next diff).
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1828