[libcxx-commits] [PATCH] D115598: [libc++][NFC] Remove goto from std::string
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Dec 12 14:21:39 PST 2021
philnik marked 2 inline comments as done.
philnik 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);
}
----------------
nilayvaish wrote:
> 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.
This code is part of the initial libc++ commit. Unless you know where to get any (svn?) log, I think this question can't be answered. The only thing I could guess is some sort of compiler limitation 12+ years ago.
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