aboutsummaryrefslogtreecommitdiffstats
path: root/prog/encodingexec.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-04-15 12:36:25 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-04-15 13:23:33 +0000
commitf887b0490140a0c80dd49d2c549ac57ac2adc2b9 (patch)
tree1517fcc39031508f1701bee8ef4078968c1fbde2 /prog/encodingexec.go
parent80ce88419762e4342971463033802fea7cdb2973 (diff)
prog: don't pad data in exec encoding
With leb128 ints it does not make any sense. Reduces exec sizes a bit more: - exec sizes: 10%:597 50%:1438 90%:7145 + exec sizes: 10%:584 50%:1423 90%:7076
Diffstat (limited to 'prog/encodingexec.go')
-rw-r--r--prog/encodingexec.go13
1 files changed, 4 insertions, 9 deletions
diff --git a/prog/encodingexec.go b/prog/encodingexec.go
index 2c13d452c..8e12d3491 100644
--- a/prog/encodingexec.go
+++ b/prog/encodingexec.go
@@ -283,7 +283,7 @@ func (w *execContext) writeArg(arg Arg) {
case *DataArg:
data := a.Data()
if len(data) == 0 {
- return
+ panic("writing data arg with 0 size")
}
w.write(execArgData)
flags := uint64(len(data))
@@ -291,16 +291,11 @@ func (w *execContext) writeArg(arg Arg) {
flags |= execArgDataReadable
}
w.write(flags)
- padded := len(data)
- if pad := 8 - len(data)%8; pad != 8 {
- padded += pad
- }
- if len(w.buf) < padded {
+ if len(w.buf) < len(data) {
w.eof = true
} else {
- copy(w.buf, data)
- copy(w.buf[len(data):], make([]byte, 8))
- w.buf = w.buf[padded:]
+ n := copy(w.buf, data)
+ w.buf = w.buf[n:]
}
case *UnionArg:
w.writeArg(a.Option)