[libcxx-commits] [libcxx] b391e80 - [libc++] Remove redundant assignments in bitset string-like constructors (#121424)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Mar 18 09:05:45 PDT 2025
Author: Peng Liu
Date: 2025-03-18T12:05:40-04:00
New Revision: b391e80f52f4248e4e2b766c25f83d5e62ef2d56
URL: https://github.com/llvm/llvm-project/commit/b391e80f52f4248e4e2b766c25f83d5e62ef2d56
DIFF: https://github.com/llvm/llvm-project/commit/b391e80f52f4248e4e2b766c25f83d5e62ef2d56.diff
LOG: [libc++] Remove redundant assignments in bitset string-like constructors (#121424)
The following three string-like constructors for `std::bitset`
- `bitset(const CharT* str, std::size_t n, CharT zero, CharT one)`;
- `bitset(const std::basic_string<CharT, Traits, Alloc>& str, typename
std::basic_string<CharT, Traits, Alloc>::size_type pos, CharT zero,
CharT one)`;
- `bitset(std::basic_string_view<CharT, Traits> str, std::size_t pos,
std::size_t n, CharT zero, CharT one)`
already initialize the underlying storage array to all zeroes via
default-constructor of the base class `__bitset`. Therefore,
re-assigning the storage array to zeroes via `std::fill_n` in the
string-like constructors is truly redundant.
Added:
Modified:
libcxx/include/bitset
Removed:
################################################################################
diff --git a/libcxx/include/bitset b/libcxx/include/bitset
index f905b6f274e3f..669a3947a87af 100644
--- a/libcxx/include/bitset
+++ b/libcxx/include/bitset
@@ -733,7 +733,6 @@ private:
_CharT __c = __str[__mp - 1 - __i];
(*this)[__i] = _Traits::eq(__c, __one);
}
- std::fill(__base::__make_iter(__i), __base::__make_iter(_Size), false);
}
_LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT { return __base::__hash_code(); }
More information about the libcxx-commits
mailing list