txscript: Reduce script parse opcode allocs. (#677)
This changes the script template parsing function to use a pointer into the constant global opcode array for parsed opcodes as opposed to making a copy of the opcode entries which causes unnecessary allocations. Profiling showed that after roughly 48 hours of operation, this copy was the culprit of 207 million unnecessary allocations.
This commit is contained in:
parent
b87723cd94
commit
644570487f
1 changed files with 2 additions and 2 deletions
|
@ -105,8 +105,8 @@ func parseScriptTemplate(script []byte, opcodes *[256]opcode) ([]parsedOpcode, e
|
|||
retScript := make([]parsedOpcode, 0, len(script))
|
||||
for i := 0; i < len(script); {
|
||||
instr := script[i]
|
||||
op := opcodes[instr]
|
||||
pop := parsedOpcode{opcode: &op}
|
||||
op := &opcodes[instr]
|
||||
pop := parsedOpcode{opcode: op}
|
||||
|
||||
// Parse data out of instruction.
|
||||
switch {
|
||||
|
|
Loading…
Reference in a new issue