Skip to content
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

txscript: Improve conditional stack. #400

Merged
merged 1 commit into from
Apr 23, 2015

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Apr 23, 2015

This pull request improves the way the conditional execution stack is handled in a few ways.

First, the current execution state is now pushed onto the end of the slice rather than the front of it. This has been done because it results in fewer allocations and is therefore more efficient.

Second, the need for allocating and setting an initial true in the conditional stack has been eliminated. The vast majority of scripts don't contain any conditionals, so there is no reason to allocate a slice when
it isn't needed.

Third, a new function has been added to the engine to determine if the current conditional branch is executing named isBranchExecuting which handles the fact the conditional execution stack can now be empty and
improves the readability of the code.

Finally, it removes a couple of TODOs which I have verified do not apply.

@davecgh davecgh force-pushed the txscript_condstack branch from cea70eb to d610589 Compare April 23, 2015 07:45
This commit improves the way the conditional execution stack is handled in
a few ways.

First, the current execution state is now pushed onto the end of the slice
rather than the front of it.  This has been done because it results in
fewer allocations and is therefore more efficient.

Second, the need for allocating and setting an initial true in the
conditional stack has been eliminated.  The vast majority of scripts don't
contain any conditionals, so there is no reason to allocate a slice when
it isn't needed.

Third, a new function has been added to the engine to determine if the
current conditional branch is executing named isBranchExecuting which
handles the fact the conditional execution stack can now be empty and
improves the readability of the code.

Finally, it removes a couple of TODOs which I have verified do not apply.
@dajohi
Copy link
Member

dajohi commented Apr 23, 2015

OK

@conformal-deploy conformal-deploy merged commit d610589 into btcsuite:master Apr 23, 2015
@davecgh davecgh deleted the txscript_condstack branch April 23, 2015 16:35
cjepson pushed a commit to cjepson/btcd that referenced this pull request Oct 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants