igorw/get-in — pull request #7 by AnhNhan (2014-01-09 21:31:39+00:00)
Title: Adding micro-optimization for non-nested keys

Optimization taken from https://github.com/facebook/libphutil/blob/master/src/utils/utils.php#L38 (`idx` is being used a *lot* in their code base & Phabricator)

This makes non-nested access ~20-30% faster, but makes nested access ~20-30% slower (might be lower for higher levels of nesting).

Times were taken on PHP 5.4.11 @ Windows

Gist of benchmark script (Inlined both functions to run both tests in the same run):
https://gist.github.com/AnhNhan/8342353

Gist of output:
https://gist.github.com/AnhNhan/8342343

If you are fine with this trade-off, then pull.

An alternative would be creating a separate function for non-nested access.