Commit 363b422983e01a532df67b2432cb13e47bf092e0 rpc: rm unneeded UniValue copies in importmulti and importdescriptors
is useless. There is not any copying happening and the old and the new code are the same wrt how many objects are being created and destroyed.
0/* The rule of five. */
1class R5
2{
3public:
4 R5(int x, double y)
5 {
6 x_ = x;
7 y_ = y;
8 std::cout << "R5::R5() this=" << this << " x=" << x_ << ", y=" << y_ << std::endl;
9 }
10
11 ~R5()
12 {
13 std::cout << "R5::~R5() this=" << this << " x=" << x_ << ", y=" << y_ << std::endl;
14 }
15
16 R5(const R5& other)
17#if 0
18 = delete;
19#else
20 {
21 std::cout << "R5::R5(const R5&) this=" << this << " other=" << &other << " x=" << other.x_
22 << ", y=" << other.y_ << std::endl;
23 x_ = other.x_;
24 y_ = other.y_;
25 }
26#endif
27
28 R5(R5&& other)
29 {
30 std::cout << "R5::R5(R5&&) this=" << this << " other=" << &other << " x=" << other.x_
31 << ", y=" << other.y_ << std::endl;
32 x_ = other.x_;
33 y_ = other.y_;
34 other.x_ = 0;
35 other.y_ = 0;
36 }
37
38 R5& operator=(const R5& other)
39#if 0
40 = delete;
41#else
42 {
43 std::cout << "R5::operator=(const R5&) this=" << this << " x=" << x_ << ", y=" << y_
44 << " other=" << &other << " x=" << other.x_ << ", y=" << other.y_ << std::endl;
45 x_ = other.x_;
46 y_ = other.y_;
47 return *this;
48 }
49#endif
50
51 R5& operator=(R5&& other)
52 {
53 std::cout << "R5::operator=(R5&&) this=" << this << " x=" << x_ << ", y=" << y_
54 << " other=" << &other << " x=" << other.x_ << ", y=" << other.y_ << std::endl;
55 x_ = other.x_;
56 y_ = other.y_;
57 other.x_ = 0;
58 other.y_ = 0;
59 return *this;
60 }
61
62 std::ostream& operator<<(std::ostream& os) { return os << "(x=" << x_ << ", y=" << y_ << ")"; }
63
64 int x_;
65 double y_;
66};
67
68R5 f()
69{
70 R5 result{1, 2.3};
71 result.x_ = 11;
72 return result;
73}
74
75int main(int, char**)
76{
77 std::cout << "before f()\n";
78 const R5 r5 = f();
79 std::cout << "after f()\n";
80
81 return 0;
82}
prints the same with const R5 r5
and with const R5& r5
.