[all-commits] [llvm/llvm-project] f1c341: [libc++] Refactor __split_buffer to eliminate code...
Peng Liu via All-commits
all-commits at lists.llvm.org
Mon Nov 4 04:54:49 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f1c341c36f1a8582163217196abf7401f81a4d2b
https://github.com/llvm/llvm-project/commit/f1c341c36f1a8582163217196abf7401f81a4d2b
Author: Peng Liu <winner245 at hotmail.com>
Date: 2024-11-04 (Mon, 04 Nov 2024)
Changed paths:
M libcxx/include/__split_buffer
M libcxx/include/__vector/vector.h
M libcxx/include/deque
Log Message:
-----------
[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.
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