Clean up some code inside interpreter.cpp #28879

issue janus opened this issue on November 15, 2023
  1. janus commented at 9:37 AM on November 15, 2023: none

    Please describe the feature you'd like to see added.

    The below code would run a bit faster.

                        // Drop the signature in pre-segwit scripts but not segwit scripts
                        if (sigversion == SigVersion::BASE) {
                            for (int k = 0; k < nSigsCount; k++)
                            {
                                valtype& vchSig = stacktop(-isig-k);
                                int found = FindAndDelete(scriptCode, CScript() << vchSig);
                                if (found > 0 && (flags & SCRIPT_VERIFY_CONST_SCRIPTCODE))
                                    return set_error(serror, SCRIPT_ERR_SIG_FINDANDDELETE);
                            }
                        }```
    
    ### Is your feature related to a problem, if so please describe it.
    
    No.
    
    ### Describe the solution you'd like
    
    The below code would only  execute the FOR loop if the sigversion matches in the external IF statement 
    
    
                    // Drop the signature in pre-segwit scripts but not segwit scripts
                    if (sigversion == SigVersion::BASE) {
                        for (int k = 0; k < nSigsCount; k++)
                        {
                            valtype& vchSig = stacktop(-isig-k);
                            int found = FindAndDelete(scriptCode, CScript() << vchSig);
                            if (found > 0 && (flags & SCRIPT_VERIFY_CONST_SCRIPTCODE))
                                return set_error(serror, SCRIPT_ERR_SIG_FINDANDDELETE);
                        }
                    }```

    Describe any alternatives you've considered

    None.

    Please leave any additional context

    This would speed up execution of code.

  2. janus added the label Feature on Nov 15, 2023
  3. fanquake removed the label Feature on Nov 15, 2023
  4. maflcko commented at 9:54 AM on November 15, 2023: member

    You'll have to provide benchmarks, if you claim that this speeds up something. Keep in mind that compilers can produce optimized executables, when passed optimization flags, without having to change any code at all.

  5. maflcko closed this on Nov 15, 2023

  6. bitcoin locked this on Nov 14, 2024
Contributors

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-17 09:13 UTC

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