Commit 0f7e0b00 authored by Kirill Smelkov's avatar Kirill Smelkov

X neo/protogen/decode: Don't cast len(data) to uint64 if we know it will be compared to constan

Improves signal/noise ratio in generated decoder.
parent c884bfd5
...@@ -751,7 +751,12 @@ func (d *decoder) overflowCheck() { ...@@ -751,7 +751,12 @@ func (d *decoder) overflowCheck() {
//d.bufDone.emit("// overflow check point") //d.bufDone.emit("// overflow check point")
if !d.overflow.checkSize.IsZero() { if !d.overflow.checkSize.IsZero() {
d.bufDone.emit("if uint64(len(data)) < %v { goto overflow }", &d.overflow.checkSize) lendata := "len(data)"
if !d.overflow.checkSize.IsNumeric() {
// symbolic checksize has uint64 type
lendata = "uint64(" + lendata + ")"
}
d.bufDone.emit("if %s < %v { goto overflow }", lendata, &d.overflow.checkSize)
// if size for overflow check was only numeric - just // if size for overflow check was only numeric - just
// accumulate it at generation time // accumulate it at generation time
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment