Conversation
The optimisation guide predated user-defined functions, global constants and imports, and framed optimisation as a bytesize-only concern. - Frame the guide around both budgets: bytesize and op-cost, and note that they pull in opposite directions for P2SH contracts. - Add a section on measuring op-cost with getVmResourceUsage(), which was documented on the TransactionBuilder but never linked from here. - Describe what the compiler already does: peephole optimisations and the inline-vs-OP_DEFINE decision for functions and constants. - Add a "Sharing code with functions and constants" section covering global constants, user-defined functions and imports. - Demote the "Combining Functions" workaround: extracting shared logic into user-defined functions is now the better first step. - Add a tip on returning multiple values from one function instead of recomputing shared work in two. Also document the nested-function call stack in the debugging guide, which was user-visible since #429 but undocumented, and fix a link to the HashType anchor that broke when it was renamed to SighashType. Correct the tuple destructuring guidance in contracts.md. It said that listing declarations before reassignments compiles smaller, but the opposite holds: visitTupleAssignment processes targets right-to-left and parks declarations on the altstack, so trailing declarations keep the stack shallower for the emitReplace calls, whose cost grows with depth. Measured at 58 / 55 / 52 bytes as the declaration moves rightwards. Every byte count quoted in the guide was measured against the exact code shown. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QbNNwhTXMdRuRBvwbjGSei
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #445 +/- ##
=======================================
Coverage ? 88.18%
=======================================
Files ? 59
Lines ? 4843
Branches ? 906
=======================================
Hits ? 4271
Misses ? 443
Partials ? 129 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The optimisation guide predated user-defined functions, global constants and imports, and framed optimisation as a bytesize-only concern.
Also document the nested-function call stack in the debugging guide, which was user-visible since #429 but undocumented, and fix a link to the HashType anchor that broke when it was renamed to SighashType.
Correct the tuple destructuring guidance in contracts.md. It said that listing declarations before reassignments compiles smaller, but the opposite holds: visitTupleAssignment processes targets right-to-left and parks declarations on the altstack, so trailing declarations keep the stack shallower for the emitReplace calls, whose cost grows with depth. Measured at 58 / 55 / 52 bytes as the declaration moves rightwards.
Every byte count quoted in the guide was measured against the exact code shown.