Query relating to privs.inc

  • Something I stumbled upon while working on a bounty related to bug #6400. There is a function that sorts the privilege array (sort_privs($priv_list)) that calls 'cmp_privkeys($a, $b)' essentially 2,600 times on every page load, which can contribute to up to 20% of the page generation time on some pages.

    I'm struggling to see why this function is even necessary given that $priv_list is an associative array, therefore the position in the array of any given key has absolutely no bearing on the time taken to access that key.

    This area is clearly ripe for some improvement, so I'd like some clarification on exactly what the intent behind sorting this array is; so I can determine whether I need to find a faster sort algorithm or if the function can simply be eliminated on most if not all pages.

Log in to reply