Skip to content

UniValue: Use operator= for setters

UniValues can be assigned to in two different ways: via efficient named setter methods and via inefficient normal assignment. This removes the first way (as much as possible), and upgrades the performance of the remaining API (by skipping the implict conversion to UniValue and subsequent move-assignment of this UniValue).

Note that this changes the integer/float setters to match operator= semantics: they now assign null on failure rather than keeping the old value, in order to get identical behaviour to the pre-existing but less efficient move-assignment operator.

A new operator=(const char*) is added to match the corresponding constructor.

In the spirit of operator= semantics, the setters return a reference to the UniValue that has been set, but for convenience the return is strongly-typed. If a strongly-typed reference cannot be returned, the return type is void (so we can always add an appropriate return type later).

This is an interface simplification in the context of #51.

Test plan: ninja check-univalue all bench_bitcoin check check-functional

Merge request reports