Skip to content

Conversation

@hebasto
Copy link
Member

@hebasto hebasto commented Dec 24, 2022

This PR makes code more succinct and readable by using move semantics.

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 24, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK martinus, achow101, TheCharlatan, MarcoFalke
Concept ACK sipa, aureleoules
Stale ACK ryanofsky

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

No conflicts as of last run.

@sipa
Copy link
Member

sipa commented Dec 31, 2022

Concept ACK

Copy link
Contributor

@aureleoules aureleoules left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

Copy link
Member

@maflcko maflcko left a 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-----

@hebasto
Copy link
Member Author

hebasto commented Jan 3, 2023

Updated 3bc1cd3 -> 94a0f7f (pr26749.01 -> pr26749.02, diff):

Copy link
Member

@maflcko maflcko left a 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-----

@hebasto
Copy link
Member Author

hebasto commented Jan 15, 2023

Updated 94a0f7f -> 1e756af (pr26749.02 -> pr26749.03, diff):

@hebasto hebasto changed the title refactor: Use move semanitcs in favour of custom swap functions refactor: Use move semanitcs instead of custom swap functions Jan 15, 2023
Copy link
Member

@maflcko maflcko left a 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-----

@maflcko
Copy link
Member

maflcko commented Jan 16, 2023

est/checkqueue_tests.cpp:165:13: error: 'vChecks' used after it was moved [bugprone-use-after-move,-warnings-as-errors]
            vChecks.resize(std::min(total, (size_t) InsecureRandRange(10)));
            ^
test/checkqueue_tests.cpp:167:21: note: move occurred here
            control.Add(std::move(vChecks));
                    ^

@hebasto hebasto marked this pull request as draft January 16, 2023 14:13
@hebasto hebasto marked this pull request as ready for review January 16, 2023 15:00
@hebasto hebasto closed this Jan 16, 2023
@hebasto hebasto reopened this Jan 16, 2023
@hebasto
Copy link
Member Author

hebasto commented Jan 16, 2023

est/checkqueue_tests.cpp:165:13: error: 'vChecks' used after it was moved [bugprone-use-after-move,-warnings-as-errors]
            vChecks.resize(std::min(total, (size_t) InsecureRandRange(10)));
            ^
test/checkqueue_tests.cpp:167:21: note: move occurred here
            control.Add(std::move(vChecks));
                    ^

Fixed. No significant changes in the output of time ./src/test/test_bitcoin -t checkqueue_tests/test_CheckQueue_Correct_* command.

@fanquake fanquake changed the title refactor: Use move semanitcs instead of custom swap functions refactor: Use move semantics instead of custom swap functions Jan 16, 2023
@hebasto
Copy link
Member Author

hebasto commented Jan 16, 2023

I'm not sure what is wrong with CI-GH integration...

CI: https://cirrus-ci.com/build/5532411732164608

@hebasto
Copy link
Member Author

hebasto commented Jan 18, 2023

Needs rebase

Rebased 39b38b8 -> 1427188 (pr26749.07 -> pr26749.08).

@hebasto
Copy link
Member Author

hebasto commented Mar 21, 2023

Updated a870025 -> 95ad70a (pr26749.15 -> pr26749.16, diff):

@martinus
Copy link
Contributor

re-ACK 95ad70a

@DrahtBot DrahtBot requested review from maflcko and sedited March 21, 2023 14:35
@achow101
Copy link
Member

ACK 95ad70a

@sedited
Copy link
Contributor

sedited commented Mar 21, 2023

re-ACK 95ad70a

@DrahtBot DrahtBot removed the request for review from sedited March 21, 2023 21:19
@maflcko
Copy link
Member

maflcko commented Mar 22, 2023

re-ACK 95ad70a 🚥

Show signature

Signature:

untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: re-ACK 95ad70ab652ddde7de65f633c36c1378b26a313a 🚥
3Jx5P5EQLnV2phsYvioBMSy53z+Oh8H+i3RnHRzSDyN/ear06Xcd0hZpgZIpjy2ToUbztFvgkSlnwG3PNzfGBQ==

@DrahtBot DrahtBot removed the request for review from maflcko March 22, 2023 09:55
@fanquake fanquake merged commit a709114 into bitcoin:master Mar 22, 2023
@hebasto hebasto deleted the 221224-move branch March 22, 2023 11:31
fanquake added a commit to bitcoin-core/gui that referenced this pull request Mar 22, 2023
…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
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Mar 23, 2023
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Mar 23, 2023
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
@bitcoin bitcoin locked and limited conversation to collaborators Mar 21, 2024
@bitcoin bitcoin unlocked this conversation Nov 29, 2024

//! 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)
Copy link
Contributor

@andrewtoth andrewtoth Nov 29, 2024

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.

Copy link
Member

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.

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.

delta1 added a commit to delta1/elements that referenced this pull request Apr 14, 2025
includes a FIXME for rpc_psbt.py that must have happened in the merge of
bitcoin/bitcoin#27200
DashCoreAutoGuix pushed a commit to DashCoreAutoGuix/dash that referenced this pull request Jul 24, 2025
knst pushed a commit to knst/dash that referenced this pull request Oct 22, 2025
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
@bitcoin bitcoin locked and limited conversation to collaborators Nov 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.