[all-commits] [llvm/llvm-project] 3b11fe: [libc][cpp::string] Don't allocate a string in ope...
Jackson Stogel via All-commits
all-commits at lists.llvm.org
Tue Jul 14 09:35:08 PDT 2026
Branch: refs/heads/users/jtstogel/realpath/string-view-assign
Home: https://github.com/llvm/llvm-project
Commit: 3b11feb41efb60b037a5e0ca8af66c27085948ed
https://github.com/llvm/llvm-project/commit/3b11feb41efb60b037a5e0ca8af66c27085948ed
Author: jtstogel <jtstogel at gmail.com>
Date: 2026-07-14 (Tue, 14 Jul 2026)
Changed paths:
M libc/src/__support/CPP/CMakeLists.txt
M libc/src/__support/CPP/string.h
M utils/bazel/llvm-project-overlay/libc/BUILD.bazel
Log Message:
-----------
[libc][cpp::string] Don't allocate a string in operator=(string_view)
This PR:
- Updates `opreator=(string_view)` to avoid allocating a temporary string: https://github.com/llvm/llvm-project/blob/67ebc4b221c3e94028b33004cd5cd08deee95048/libc/src/__support/CPP/string.h#L106-L108
- Changes `operator+=(const string&)` to accept a `string_view` so that strings may be appended without allocation.
- Adds asserts to make it clear that `cpp::string` does not support self assignment. Currently, `cpp::string s = "abc"; s = s;` will zero out the string.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list