mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-10 07:00:53 +00:00
libsysprof-analyze: short-circuit when address > max
This adds an O(1) check at the head of the lookup to avoid looking at every RB_RIGHT() in the tree when address falls beyond the upper bound of the interval tree.
This commit is contained in:
@ -178,6 +178,13 @@ sysprof_symbol_cache_lookup (SysprofSymbolCache *self,
|
|||||||
|
|
||||||
node = RB_ROOT(&self->head);
|
node = RB_ROOT(&self->head);
|
||||||
|
|
||||||
|
/* The root node contains our calculated max as augmented in RBTree.
|
||||||
|
* Therefore, we can know if @address falls beyond the upper bound
|
||||||
|
* in O(1) without having to add a branch to the while loop below.
|
||||||
|
*/
|
||||||
|
if (node == NULL || node->max < address)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
while (node != NULL)
|
while (node != NULL)
|
||||||
{
|
{
|
||||||
g_assert (RB_LEFT(node, link) == NULL ||
|
g_assert (RB_LEFT(node, link) == NULL ||
|
||||||
|
|||||||
Reference in New Issue
Block a user