btcd icon indicating copy to clipboard operation
btcd copied to clipboard

mempool,txscript: avoid big array copies in for-range

Open quasilyte opened this issue 6 years ago • 2 comments

When array is used in place of range expression, whole array is copied. Using &array avoids this issue.

Found using https://go-critic.github.io/overview#rangeExprCopy-ref

Linter output:

$GOPATH/src/github.com/btcsuite/btcd/mempool/estimatefee.go:513:2: rangeExprCopy: copy of ef.bin (600 bytes) can be avoided with &ef.bin
$GOPATH/src/github.com/btcsuite/btcd/mempool/estimatefee.go:522:2: rangeExprCopy: copy of ef.bin (600 bytes) can be avoided with &ef.bin
$GOPATH/src/github.com/btcsuite/btcd/mempool/estimatefee.go:659:2: rangeExprCopy: copy of ef.bin (600 bytes) can be avoided with &ef.bin
$GOPATH/src/github.com/btcsuite/btcd/txscript/opcode.go:2440:2: rangeExprCopy: copy of opcodeArray (10240 bytes) can be avoided with &opcodeArray

quasilyte avatar Sep 13 '18 21:09 quasilyte

@jcvernaleo (as per #1530)

  • Low priority
  • Enhancement

jakesylvestre avatar Mar 04 '20 14:03 jakesylvestre

Can you rebase or force-push so CI can run?

jakesylvestre avatar Dec 08 '20 18:12 jakesylvestre