[libcxx-commits] [PATCH] D115598: [libc++][NFC] Remove goto from std::string
Nilay Vaish via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Dec 12 14:18:09 PST 2021
nilayvaish accepted this revision.
nilayvaish added inline comments.
================
Comment at: libcxx/include/string:3223
_LIBCPP_ASSERT(!empty(), "string::pop_back(): string is already empty");
- size_type __sz;
- if (__is_long())
- {
- __sz = __get_long_size() - 1;
- __set_long_size(__sz);
- traits_type::assign(*(__get_long_pointer() + __sz), value_type());
- }
- else
- {
- __sz = __get_short_size() - 1;
- __set_short_size(__sz);
- traits_type::assign(*(__get_short_pointer() + __sz), value_type());
- }
- __invalidate_iterators_past(__sz);
+ __null_terminate_at(__get_pointer(), size() - 1);
}
----------------
Quuxplusone wrote:
> Huh. Anyone got any idea why the left-hand code was so... hand-inlined? Anything in the `git log` that sheds light on this? Ditto `__erase_to_end` below.
I think we want to avoid checking whether the string is long or short again and again. Would likely save a few cycles.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115598/new/
https://reviews.llvm.org/D115598
More information about the libcxx-commits
mailing list