Skip to content

Commit 43cd31e

Browse files
authored
core/vm: dedup config check in markdown logger (#21655)
* core/vm: dedup config check * review feedback: reuse buffer
1 parent 5e86e4e commit 43cd31e

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎core/vm/logger.go‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,20 +322,21 @@ func (t *mdLogger) CaptureStart(from common.Address, to common.Address, create b
322322
func (t *mdLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost uint64, memory *Memory, stack *Stack, rStack *ReturnStack, rData []byte, contract *Contract, depth int, err error) error {
323323
fmt.Fprintf(t.out, "| %4d | %10v | %3d |", pc, op, cost)
324324

325-
if !t.cfg.DisableStack { // format stack
325+
if !t.cfg.DisableStack {
326+
// format stack
326327
var a []string
327328
for _, elem := range stack.data {
328329
a = append(a, fmt.Sprintf("%d", elem))
329330
}
330331
b := fmt.Sprintf("[%v]", strings.Join(a, ","))
331332
fmt.Fprintf(t.out, "%10v |", b)
332-
}
333-
if !t.cfg.DisableStack { // format return stack
334-
var a []string
333+
334+
// format return stack
335+
a = a[:0]
335336
for _, elem := range rStack.data {
336337
a = append(a, fmt.Sprintf("%2d", elem))
337338
}
338-
b := fmt.Sprintf("[%v]", strings.Join(a, ","))
339+
b = fmt.Sprintf("[%v]", strings.Join(a, ","))
339340
fmt.Fprintf(t.out, "%10v |", b)
340341
}
341342
fmt.Fprintln(t.out, "")

0 commit comments

Comments
 (0)