HomePhabricator

Support deserializing into temporaries

Authored by Pieter Wuille <pieter.wuille@gmail.com> on Jul 8 2017, 02:09.

Description

Support deserializing into temporaries

Summary:
Backported commit 2/2 (172f5fa738) from PR12683

Original summary:
Currently, the READWRITE macro cannot be passed any non-const temporaries, as
the SerReadWrite function only accepts lvalue references.

Deserializing into a temporary is very common, however. See for example
things like 's >> VARINT(n)'. The VARINT macro produces a temporary wrapper
that holds a reference to n.

Fix this by accepting non-const rvalue references instead of lvalue references.
We don't propagate the rvalue-ness down, as there are no useful optimizations
that only apply to temporaries.

Then use this new functionality to get rid of many (but not all) uses of the
'REF' macro (which casts away constness).

Depends on D2930.

Test Plan: make check

Reviewers: #bitcoin_abc, deadalnix, Fabien

Reviewed By: #bitcoin_abc, Fabien

Maniphest Tasks: T634

Differential Revision: https://reviews.bitcoinabc.org/D2931

Details

Committed
Mark Lundeberg <36528214+markblundeberg@users.noreply.github.com>May 9 2019, 15:58
Pushed
markblundebergMay 9 2019, 15:58
Reviewer
Restricted Project
Differential Revision
D2931: Support deserializing into temporaries
Parents
rABC2a64216d4da6: Merge READWRITEMANY into READWRITE
Branches
Unknown
Tags
Unknown

Event Timeline

Mark Lundeberg <36528214+markblundeberg@users.noreply.github.com> committed rABC732f92fa1f60: Support deserializing into temporaries (authored by Pieter Wuille <pieter.wuille@gmail.com>).May 9 2019, 15:58