refactor: Move result instead of copy in Solver() #16019

pull promag wants to merge 1 commits into bitcoin:master from promag:2019-05-solver-nit changing 1 files +3 −3
  1. promag commented at 5:40 PM on May 13, 2019: member

    Move vector witnessprogram instead of copying. Also drop unnecessary std::vector::clear().

  2. DrahtBot added the label Refactoring on May 13, 2019
  3. in src/script/standard.cpp:155 in a7a912b7d5 outdated
     151 | @@ -152,7 +152,6 @@ txnouttype Solver(const CScript& scriptPubKey, std::vector<std::vector<unsigned
     152 |          return TX_MULTISIG;
     153 |      }
     154 |  
     155 | -    vSolutionsRet.clear();
    


    MarcoFalke commented at 6:20 PM on May 13, 2019:

    The clear here is for documentation purposes (and clearing an empty vector is free anyway)


    promag commented at 9:09 PM on May 13, 2019:

    If it's documentation then maybe change to assert(vSolutionsRet.empty())?


    Empact commented at 3:13 AM on May 17, 2019:

    Would suggest keeping the line - it enforces an invariant against future change, and would be good to consider it separately if we are to change it. assert could be overkill given this is basically a failure case anyway.


    jb55 commented at 3:04 PM on May 18, 2019:

    yeah but assert would catch a situation where you missed a return higher up which is something that would definitely be good to catch right away.


    promag commented at 1:34 PM on May 20, 2019:

    Now using assert(...). It's an unrelated change and I don't mind dropping it but either way assert() looks better to me.

  4. MarcoFalke commented at 6:20 PM on May 13, 2019: member

    How much are the speedups?

  5. promag commented at 9:08 PM on May 13, 2019: member

    @MarcoFalke didn't measured, but think there's no noticeable speedup. I'm just doing the same as L120.

  6. refactor: Move result instead of copy in Solver() 1c12a262d7
  7. promag force-pushed on May 20, 2019
  8. laanwj commented at 10:18 AM on May 29, 2019: member

    I'd prefer to keep this code simpler if there's no noticable speedup.

  9. promag commented at 6:06 PM on May 29, 2019: member

    @laanwj not even replacing clear() with the assert()?

  10. promag closed this on Jun 3, 2019

  11. promag deleted the branch on Jun 3, 2019
  12. DrahtBot locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-22 00:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me