[libcxx-commits] [PATCH] D123058: [libc++] Remove the usage of __init in operator+

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Apr 6 09:51:20 PDT 2022


ldionne added a comment.

We just looked at the codegen for the current code and the `reserve`-based version, and the `reserve`-based version ends up calling `reserve`, `append` and `push_back` separately, whereas the old version is simpler (it calls `operator new` and `memcpy` directly): https://godbolt.org/z/EWs78arre. I think this is due to the fact that the old version (with `__init`) can assume that we don't have any constructed state before, so it doesn't need to be as complicated. Also, `push_back` is exported in the dylib (which is a strange choice IMO since we ought to have a fast path). Can you run a quick benchmark to see if there's a noticeable difference? If so, we could go with this patch but also try to provide a fast path for `push_back` (which is probably a good idea regardless).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123058/new/

https://reviews.llvm.org/D123058



More information about the libcxx-commits mailing list