This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix __gnu_cxx::throw_allocator 2 * O(log(N)) complexity


On 13/11/18 07:15 +0100, François Dumont wrote:
Oops, it was not the tested patch. Here it is.

On 11/12/18 7:43 AM, François Dumont wrote:
When doing some debugging session I noticed that the __gnu_cxx::throw_allocator doubles all lookup on both insert and erase.

Using map::insert result and erasing the found iterator avoids this double lookup.

    * include/ext/throw_allocator.h
    (annotate_base::insert(void*, size_t)): Use insert result to check for
    double insert attempt.
    (annotate_base::insert_construct(void*)): Likewise.
    (annotate_base::check_allocated(void*, size_t)): Return found iterator.
    (annotate_base::erase(void*, size_t)): Use latter method returned
    iterator.
    (annotate_base::check_constructed(void*, size_t)): Return found iterator.
    (annotate_base::erase_construct(void*)): Use latter method returned
    iterator.

Tested under linux x86_64.

Ok to commit ?

OK, thanks.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]