diff options
author | Peng Liu <winner245@hotmail.com> | 2024-11-04 07:54:26 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-04 13:54:26 +0100 |
commit | f1c341c36f1a8582163217196abf7401f81a4d2b (patch) | |
tree | 08142b0475c7d45b2c1684406438367b4c452237 /clang/tools/include-mapping/cppreference_parser.py | |
parent | 7bf0d6d032c5ef04a0f4966df8760664aaefc871 (diff) | |
download | llvm-f1c341c36f1a8582163217196abf7401f81a4d2b.zip llvm-f1c341c36f1a8582163217196abf7401f81a4d2b.tar.gz llvm-f1c341c36f1a8582163217196abf7401f81a4d2b.tar.bz2 |
[libc++] Refactor __split_buffer to eliminate code duplication (#114138)
This PR refactors the `__split_buffer` class to eliminate code
duplication in the `push_back` and `push_front` member functions.
**Motivation:**
The lvalue and rvalue reference overloads of `push_back` share identical
logic, which coincides with that of `emplace_back`. Similarly, the
overloads of `push_front` also share identical logic but lack an
`emplace_front` member function, leading to an inconsistency. These
identical internal logics lead to significant code duplication, making
future maintenance more difficult.
**Summary of Refactor:**
This PR reduces code redundancy by:
1. Modifying both overloads of `push_back` to call `emplace_back`.
2. Introducing a new `emplace_front` member function that encapsulates
the logic of `push_front`, allowing both overloads of `push_front` to
call it (The addition of `emplace_front` also avoids the inconsistency
regarding the absence of `emplace_front`).
The refactoring results in reduced code duplication, improved
maintainability, and enhanced readability.
Diffstat (limited to 'clang/tools/include-mapping/cppreference_parser.py')
0 files changed, 0 insertions, 0 deletions