Fix __gnu_cxx::throw_allocator 2 * O(log(N)) complexity
François Dumont
frs.dumont@gmail.com
Tue Nov 13 06:15:00 GMT 2018
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 ?
>
> François
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: throw_allocator.patch
Type: text/x-patch
Size: 4308 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20181113/a7a4940d/attachment.bin>
More information about the Libstdc++
mailing list