mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-09 12:50:18 +02:00
Merge bitcoin/bitcoin#26992: refactor: Remove unused CDataStream SerializeMany constructor
fa47b28dfc2a6577519e10da68ebd8da93568434 refactor: Remove unused CDataStream SerializeMany constructor (MarcoFalke) Pull request description: Seems odd to have an unused method. Moreover, the function is fragile and dangerous, because one could have a `std::vector vec_a` and type `CDataStream{vec_a, 0, 0}.size()` and `CDataStream{0, 0, vec_a}.size()`, assuming they are the same thing, when in fact they are not. (The first takes over the memory as is, the second serializes the vector). So my suggestion would be to remove the unused method and introduce a new method when this functionality is needed. For example: `static DataStream FromMany(Args&&... args)`. ACKs for top commit: stickies-v: ACK fa47b28dfc2a6577519e10da68ebd8da93568434 Tree-SHA512: 9593a034b997e33a0794f779f76f02425b1097b218cf8cb1facb7f874fa69da328ce567a79138015baeebe004ae7d103dda4f64f83e8ad375b6dae6b66d3d950
This commit is contained in:
commit
21138fe377
@ -358,14 +358,6 @@ public:
|
||||
nType{nTypeIn},
|
||||
nVersion{nVersionIn} {}
|
||||
|
||||
template <typename... Args>
|
||||
CDataStream(int nTypeIn, int nVersionIn, Args&&... args)
|
||||
: nType{nTypeIn},
|
||||
nVersion{nVersionIn}
|
||||
{
|
||||
::SerializeMany(*this, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
int GetType() const { return nType; }
|
||||
void SetVersion(int n) { nVersion = n; }
|
||||
int GetVersion() const { return nVersion; }
|
||||
|
@ -237,7 +237,8 @@ BOOST_AUTO_TEST_CASE(class_methods)
|
||||
BOOST_CHECK(methodtest2 == methodtest3);
|
||||
BOOST_CHECK(methodtest3 == methodtest4);
|
||||
|
||||
CDataStream ss2(SER_DISK, PROTOCOL_VERSION, intval, boolval, stringval, charstrval, txval);
|
||||
CDataStream ss2{SER_DISK, PROTOCOL_VERSION};
|
||||
ss2 << intval << boolval << stringval << charstrval << txval;
|
||||
ss2 >> methodtest3;
|
||||
BOOST_CHECK(methodtest3 == methodtest4);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user