-
Notifications
You must be signed in to change notification settings - Fork 38.6k
refactor: Use move semantics instead of custom swap functions #26749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsNo conflicts as of last run. |
|
Concept ACK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 3bc1cd3 🍈
Show signature
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
3bc1cd3b4ae41182de0c05339adb2a2ad6774aeb 🍈
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUjBAQwAyTiOXLVPCGwxsPgc5OPOqkmFqbJ7Oo8hdydTkqEd45XqRyqwBrYbHrBj
mo41rCU+v5RpD2nfsoRGRYAlHe3aopTLwIqxWfX9OV9//S5W+ETie0Ve2MjPXmrG
Qe+K3201o/SmrQb0KdXCzNTqTY/W6qwxcI4Kh1aTItKKM6qaz+9OkhIcopPSr+55
WTB9IHO5fThCNwECczPSX03KjXO9lnDYoQywLAcczM+/63+QF8Fc/TZ3WMyR4s+O
tahA6AAHt4UD9T5EZlEmSdjDN5rlaFm/a1MRLMZJLRnHxq7rmH5FPBsR5LhoDybg
VC0Tr5FLfCOzmyoozJfsC2lJp1NXnapMG2sXCyncm29aFlUs/bDoN+O930DsynJU
UI0U909eDrWZY18KgB5Tk264asTBuG0gD66y7FNkDirlOTGZWnk1XGFWbm72DEzx
dpTT1izyc3cMgYuvvAo705vVd4e0wOACyQMu0RdxWUEzVl2yKC4Sk0p6Dqs7Li2O
hATac7RZ
=M4q3
-----END PGP SIGNATURE-----
|
Updated 3bc1cd3 -> 94a0f7f (pr26749.01 -> pr26749.02, diff):
|
maflcko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review ACK 94a0f7f 🗓
Show signature
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
review ACK 94a0f7f0d1 🗓
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUgcYgv+PDGjv8xGOwQ9E4gnqlo8Lw0J2zDZtxwYcqrJPyTyxNadiNawnrRy/emu
gW7k33BUKg6PuAoV87vk2LF2GIWhuefE/p5lt9Rs5ROVkg0ihDugowRLo7BBURyQ
nGiTUc8I9hZWlerxIUoS1hohkOYbp9U4gcOmFz6lxUlAp4rRMVVkN08s59jQ/CHw
PZId7DZOBYFIzqwIzxVoaAH4p2MpwH1MLVmRNH/yB94HWbBFVJPeMmrlQm0Et2vq
6ci/luQmtq8jdv3V/7jHfKjEzJmm/ZvV51q6lZQciOkrO3mIZmS9rH0aFzNRpXMZ
NyvV7wM7HUZOYpz/yhMv/mYZTAsYd1guEvgouA7s+WPVbJbWN6fZcmLTYX0zvgBb
ZQ2pHnsFUVAh0zHyeRtY8G0LrAEqlfRS/YcNEMIjfx9P6fC71j5VXk50dGDP9JY7
tmK2DsojffQRevWyl05MfXiUyXIKaAMg5m+hotGDKDB6zF2GcumTjoulG323hwWQ
ohfSHz4o
=dRH3
-----END PGP SIGNATURE-----
|
Updated 94a0f7f -> 1e756af (pr26749.02 -> pr26749.03, diff):
|
maflcko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-ACK 1e756af 👃
Show signature
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
re-ACK 1e756af73431724990e893864eb3124ee07cee61 👃
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUiuVQv/UVlprocEW7xqeGKqlaEUMFXWKvCXUUWqANRb9yc8vh3qwg0KLTTkjseX
iPBL7bv3IkudVKzY1xcXFq0fmmnCi7BdxqA0IfWlNMrRjWEoGy8vNNIzsfnJZJ+a
SirjXtLZ6gXOQorz6c4ZBg+W0sDafFFv1cbHud07gUqbvtXi8u01SWNNPV6ezqmE
xNuzx6iM62h2aM7HQzNLL/DqnNncFTDQYhgwrofz7v7mv+aEjcT3NGxhpKxNegAZ
LW1JUzUTMvmR1wO3BiBtIuBp6nLnpuuri5kLeptUQfNIUYGFPci1OzYryiKwTwd3
MB6ZJMSjEaahRdWzTXmUDSIuTsyTEol5WcFETcgx1teDusZ1/FhX5LbzU4ANY/44
JdWZa3IliEIME0y2Lgva/KyegFgpWPcD0unE8rYrEjOLJwC2UluunMachDNjeVeX
2ItITya0ARcNuzV1LWYM71SySVJjp4UeiIaVCH12Z1q/2ET8SNS0eul49eJP4MkH
630hn0yE
=tqRi
-----END PGP SIGNATURE-----
|
Fixed. No significant changes in the output of |
|
I'm not sure what is wrong with CI-GH integration... |
Rebased 39b38b8 -> 1427188 (pr26749.07 -> pr26749.08). |
Co-authored-by: Martin Leitner-Ankerl <[email protected]>
It is safe now, when move semantics is used instead of a custom swap function.
|
Updated a870025 -> 95ad70a (pr26749.15 -> pr26749.16, diff):
|
|
re-ACK 95ad70a |
|
ACK 95ad70a |
|
re-ACK 95ad70a |
|
re-ACK 95ad70a 🚥 Show signatureSignature: |
…ructors fae3490 test: Remove unused Check* default constructors (MarcoFalke) Pull request description: They are no longer needed after the removal of `swap`, see bitcoin/bitcoin#26749 (comment) Also, flatten a redundant `if` check. ACKs for top commit: hebasto: ACK fae3490 Tree-SHA512: c0bc0c16b5df0f16fc25e18d2414a2a3c4769da1aa30d53f8d267bc2e97dd79a0296db94c1e49cd1ca89bd42275d8c462f7bf47f03f105dfe867ebea6563454b
fae3490 test: Remove unused Check* default constructors (MarcoFalke) Pull request description: They are no longer needed after the removal of `swap`, see bitcoin#26749 (comment) Also, flatten a redundant `if` check. ACKs for top commit: hebasto: ACK fae3490 Tree-SHA512: c0bc0c16b5df0f16fc25e18d2414a2a3c4769da1aa30d53f8d267bc2e97dd79a0296db94c1e49cd1ca89bd42275d8c462f7bf47f03f105dfe867ebea6563454b
|
|
||
| //! Add a batch of checks to the queue | ||
| void Add(std::vector<T>& vChecks) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) | ||
| void Add(std::vector<T>&& vChecks) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this change has any affect, aside from requiring std::move at the callsite.
In the method body we are only moving out of the individual elements, leaving a hollow element in its place. However, the actual vector vChecks is not moved so this would not have any change over using a regular lvalue reference.
This would be a benefit if somewhere in here we took ownership of vChecks, like
if (queue.empty()) {
queue = std::move(vChecks);
}
```
Actually, even then it wouldn't matter because we can move out of the lvalue reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this change has any affect, aside from requiring
std::moveat the callsite.
Yes, and the benefits of requiring std::move are:
- Self-documenting code, to mark an object as used.
- use-after-move static analysis to catch violations, where a depleted object is re-used.
includes a FIXME for rpc_psbt.py that must have happened in the merge of bitcoin/bitcoin#27200
fae3490 test: Remove unused Check* default constructors (MarcoFalke) Pull request description: They are no longer needed after the removal of `swap`, see bitcoin#26749 (comment) Also, flatten a redundant `if` check. ACKs for top commit: hebasto: ACK fae3490 Tree-SHA512: c0bc0c16b5df0f16fc25e18d2414a2a3c4769da1aa30d53f8d267bc2e97dd79a0296db94c1e49cd1ca89bd42275d8c462f7bf47f03f105dfe867ebea6563454b
This PR makes code more succinct and readable by using move semantics.