Skip to content
Snippets Groups Projects
  • Per Hedbor's avatar
    45df9023
    Changed worst-case ordo of replace(array,item1,item2) from O(n^2) to O(n). · 45df9023
    Per Hedbor authored
    Replace uses search_array, which in turn calls
    check_array_for_destruct.  So, if you had an array where all elements
    were replaced by the replace containing at least one object replace()
    was O(n^2), not O(n).
    
    In general check_array_for_destruct is rather unneeded, since the
    comparison functions already checks for destructed objects, but I
    guess that it might cause objects to be free:d slightly sooner.
    45df9023
    History
    Changed worst-case ordo of replace(array,item1,item2) from O(n^2) to O(n).
    Per Hedbor authored
    Replace uses search_array, which in turn calls
    check_array_for_destruct.  So, if you had an array where all elements
    were replaced by the replace containing at least one object replace()
    was O(n^2), not O(n).
    
    In general check_array_for_destruct is rather unneeded, since the
    comparison functions already checks for destructed objects, but I
    guess that it might cause objects to be free:d slightly sooner.