Skip to content

Add ReadList helper#285

Open
ViniciusCestarii wants to merge 2 commits into
bitcoin-core:masterfrom
ViniciusCestarii:add-readlist-helper
Open

Add ReadList helper#285
ViniciusCestarii wants to merge 2 commits into
bitcoin-core:masterfrom
ViniciusCestarii:add-readlist-helper

Conversation

@ViniciusCestarii

@ViniciusCestarii ViniciusCestarii commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Follow up of #277 (review). This adds ReadList helper and uses it to dedup the CustomReadField implementations for std::map, std::set, std::unordered_set, and std::vector, mirroring the existing BuildList helper on the build side.

I took the liberty of adding the commit f2a734a "type: reserve first when reading std::unordered_set" so it reserves the correct capacity first and then emplaces the values.

@DrahtBot

DrahtBot commented Jun 3, 2026

Copy link
Copy Markdown

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK ryanofsky

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

No conflicts as of last run.

@ryanofsky ryanofsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK f2a734a. Thanks for the followup. Plan to review more after #277 is merged

Comment thread include/mp/type-map.h Outdated
return *EmplacePiecewiseSafe(value, std::forward<decltype(args)>(args)...).first;
}));
}
ReadList(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit "proxy: add ReadList helper and dedup map/set/vector read handlers" (2bc6cb7)

Not sure if possible but it might be good to pass read_dest instead of value to the ReadList function so callers don't need to call read_dest.update and repeat as much code. This would make ReadList and BuildList more similar in how they are called. Looks like this would require adding auto& value parameters to init and emplace functions, which could also be good because it will declare value closer to where it is used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I will take a look on this approach

@ViniciusCestarii

Copy link
Copy Markdown
Contributor Author

Forced push 245f792 to just rebase with master

@ViniciusCestarii

Copy link
Copy Markdown
Contributor Author

Forced push 5d23f83 applying @ryanofsky suggestion. It reads cleaner and dedup more code.

@ViniciusCestarii ViniciusCestarii marked this pull request as ready for review June 11, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants