libhybris/libhybris — pull request #46 by thp (2013-05-06 14:48:57+00:00)
Title: Hooks: Use binary search for hooked symbol lookup

This change makes lookup cost bigger for the first lookup, as the
hooks will be sorted for binary search. Subsequent lookups should
be faster, especially non-hooked symbol lookups.

Hooks could be sorted in the source code to avoid sorting at run
time, but this has not been done here to avoid lookup bugs because
of an unsorted hook list (would be trivial to do, though - remove
the sorting code and sort the struct _hook hooks[] in the source).

Lookups will be faster than linear search, especially for lookups
for symbols that are not hooked (log2(n) instead of n comparisons).