Skip to content

Conversation

@maflcko
Copy link
Member

@maflcko maflcko commented Jul 30, 2022

Merge will create several copies unconditionally:

  • To initialize the args a, and b
  • ret, which is the merge of the two args

So change the code to let the caller decide how many copies they need/want:

  • a, and b must be explicitly moved or copied by the caller
  • ret is no longer needed, as a can be used for it in place "for free"

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 30, 2022

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #24149 (Signing support for Miniscript Descriptors by darosior)
  • #22838 (descriptors: Be able to specify change and receiving in a single descriptor string by achow101)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@achow101
Copy link
Member

achow101 commented Aug 4, 2022

Related is #16116. Could you also pull in the benchmark from that?

@achow101
Copy link
Member

achow101 commented Aug 8, 2022

ACK fa00d8f84dca8ad9c5a3580e0f7a027f472cdc41

@achow101
Copy link
Member

achow101 commented Aug 8, 2022

Silent merge conflict with master

maflcko pushed a commit to bitcoin-core/gui that referenced this pull request Aug 12, 2022
…pansion

4786959 bench: Add a benchmark for descriptor expansion (Ben Woosley)

Pull request description:

  Taken from bitcoin/bitcoin#16116 , as requested here: bitcoin/bitcoin#25748 (comment)

ACKs for top commit:
  achow101:
    ACK 4786959

Tree-SHA512: f2efdf8f84e1783c7c298abe65123191d25cab0a9da2d0ff5957a60acc2d10e356151d7ecec0d98d28c456f42ddef50efd70c7edc0c9012df2a977e080515b9d
@maflcko
Copy link
Member Author

maflcko commented Aug 12, 2022

Rebased and used @Empact's idea to transform this into a member function from https://github.com/bitcoin/bitcoin/pull/16116/files (thanks), which is a lot faster than an elided copy and std::move(). I've kept the argument as r-ref to allow stealing the pointers, which again should be faster than copying the entries individually.

Copy link
Member

@furszy furszy left a comment

Choose a reason for hiding this comment

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

looks good, ACK fa3f15f

@achow101
Copy link
Member

ACK fa3f15f

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 12, 2022
4786959 bench: Add a benchmark for descriptor expansion (Ben Woosley)

Pull request description:

  Taken from bitcoin#16116 , as requested here: bitcoin#25748 (comment)

ACKs for top commit:
  achow101:
    ACK 4786959

Tree-SHA512: f2efdf8f84e1783c7c298abe65123191d25cab0a9da2d0ff5957a60acc2d10e356151d7ecec0d98d28c456f42ddef50efd70c7edc0c9012df2a977e080515b9d
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK fa3f15f. Confirmed that all the places std::move was added the argument actually did seem safe to move from. Compiler enforces that temporary copies are explicitly created in non-move cases.

@achow101 achow101 merged commit a8f6954 into bitcoin:master Aug 17, 2022
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 18, 2022
fa3f15f refactor: Avoid copies in FlatSigningProvider Merge (MacroFake)

Pull request description:

  `Merge` will create several copies unconditionally:
  * To initialize the args `a`, and `b`
  * `ret`, which is the merge of the two args

  So change the code to let the caller decide how many copies they need/want:
  * `a`, and `b` must be explicitly moved or copied by the caller
  * `ret` is no longer needed, as `a` can be used for it in place "for free"

ACKs for top commit:
  achow101:
    ACK fa3f15f
  furszy:
    looks good, ACK fa3f15f
  ryanofsky:
    Code review ACK fa3f15f. Confirmed that all the places `std::move` was added the argument actually did seem safe to move from. Compiler enforces that temporary copies are explicitly created in non-move cases.

Tree-SHA512: 7c027ccdea1549cd9f37403344ecbb76e008adf545f6ce52996bf95e89eb7dc89af6cb31435a9289d6f2eea1c416961b2fb96348bc8a211d550728f1d99ac49c
@maflcko maflcko deleted the 2207-merge-🚗 branch August 19, 2022 08:50
@bitcoin bitcoin locked and limited conversation to collaborators Aug 19, 2023
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.

6 participants