mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:47:36 +00:00
refactor: Use std::erase and std::erase_if #36682
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36682
Loading…
Reference in a new issue
No description provided.
Delete branch "2610-erase-if"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Convert
removeandremove_ifto the C++20std::eraseandstd::erase_ifoverloads.The legacy ones can be confusing, because:
bugprone-inaccurate-erase) can be a bug, see also https://github.com/bitcoin/bitcoin/pull/36588#discussion_r4345799022. So a call only to "remove" will not erase.Also convert simple iterator-erase (which is verbose, but fine) to the std overload.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.I found no actionable issues in this static review.
Base:
0f27bed5b292· Head:fa87bfe31dfd· Full review reportACK
fa87bfe31dThe old
erase()+remove()pattern is indeed error-prone, and translating the raw loops into named and shorter constructs is good.nit: Have a slight preference for pre-existing approach when it's shorter. Although consistency is also nice.
Yeah, in C++-speak "remove" has two meanings: It means erase for std::list (unless you incorrectly use the iterator-based or range-based remove on the list, in which case it means move) and it means just move for array-based containers. I think consistently using "erase" to mean erase seems better than having to manually decipher what "remove" means in this context.
Concept ACK
ACK
fa87bfe31dACK
fa87bfe31d