mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-22 20:05:05 +02:00
fa73ed467crefactor: Fix redundant conversion to std::string and then to std::string_view [performance-string-view-conversions] (MarcoFalke)fa270fdacfrefactor: Return std::optional from GetProxy (MarcoFalke)faeac1a931refactor: Return std::optional from GetNameProxy (MarcoFalke) Pull request description: Currently the getters have a mutable reference as inout param and return a bool to indicate success. This is confusing, because the success bool is redundant with the `IsValid()` state on the proxy object. So in theory, the functions could reset the mutable proxy object to an invalid state and return `void`. However, this would also be confusing, because devs can forget to check `IsValid()`. Fix all issues by using `std::optional<Proxy>`, where devs no longer have to check `IsValid()` manually, or a separate bool. Note that new code in the repo is already using `std::optional<Proxy>`, see `git grep 'std::optional<Proxy>' bitcoin-core/master`. Also, `std::optional<Proxy>` will enforce checking at compile time, whereas calling `Proxy::IsValid` is not enforced. ACKs for top commit: achow101: ACKfa73ed467csedited: ACKfa73ed467cViniciusCestarii: ACKfa73ed467cfrankomosh: Code Review ACKfa73ed467c. Good refactor, correctly replaces the bool + mutable reference output parameter pattern with `std::optional<Proxy>` across `GetProxy` and `GetNameProxy`. Semantics are preserved. Tree-SHA512: c6a1e1d1691958d2e6507e32e3484f96703fba03ccc710145ae2fb84b1254fb0e6e1d8d78e9b572daf5ea485247b73568704881762379b50bcf939a35494dd13
162 KiB
162 KiB