[libcxx-commits] [libcxx] [libc++] Refactor __split_buffer to eliminate code duplication (PR #114138)
Peng Liu via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 30 06:48:29 PDT 2024
winner245 wrote:
Thank you, philnik777, for your insightful feedback. I also appreciate frederick-vs-ja's assistance in clarifying the purpose of my refactor, which effectively highlighted the code duplication issue with the current `push_front` implementation.
Considering philnik777's suggestion to replace any uses of `__split_buffer::push_front` and `__split_buffer::push_back` with their `emplace_xxx` equivalents, I reviewed the current usage of `__split_buffer`. It appears that it is primarily utilized by `std::vector` and `std::deque`. Therefore, the proposed changes based on philnik777's suggestion would be:
- Remove the two overloads of `__split_buffer::push_back` and retain only `__split_buffer::emplace_back`.
- Remove the two overloads of `__split_buffer::push_front`, while adding `__split_buffer::emplace_front` (noting that `__split_buffer` currently does not provide `emplace_front`).
- Modify `std::vector` and `std::deque` to replace all instances of `__split_buffer::push_front` and `__split_buffer::push_back` with the `emplace_xxx` methods.
This approach seems to provide a more comprehensive refactor. However, I would like to hear @ldionne and @frederick-vs-ja's perspectives on this before proceeding. Thank you.
https://github.com/llvm/llvm-project/pull/114138
More information about the libcxx-commits
mailing list