HomePhabricator

Support deserializing into temporaries

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

Provenance
Pieter Wuille <pieter.wuille@gmail.com>Authored on Jul 8 2017, 02:09
Mark Lundeberg <36528214+markblundeberg@users.noreply.github.com>Committed on May 9 2019, 15:58
markblundebergPushed on May 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