Commit dca2750d authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 604c81aa
...@@ -479,17 +479,14 @@ func (e *encoder) generatedCode() string { ...@@ -479,17 +479,14 @@ func (e *encoder) generatedCode() string {
return code.String() return code.String()
} }
// XXX place? // XXX place? naming?
// data <- data[pos:] // data <- data[pos:]
// // nread += pos XXX clarify about nread update
// pos <- 0 // pos <- 0
func (d *decoder) resetPos() { func (d *decoder) resetPos() {
if d.n != 0 { if d.n != 0 {
d.emit("data = data[%v:]", d.n) d.emit("data = data[%v:]", d.n)
//d.emit("%v += %v", d.var_("nread"), d.n)
}
d.n = 0 d.n = 0
}
} }
// XXX place? // XXX place?
...@@ -507,6 +504,7 @@ func (d *decoder) resetPos() { ...@@ -507,6 +504,7 @@ func (d *decoder) resetPos() {
// it is inserted // it is inserted
// - before reading a variable sized item // - before reading a variable sized item
// - in the beginning of a loop inside // - in the beginning of a loop inside
// - right after loop exit
func (d *decoder) overflowCheckPoint() { func (d *decoder) overflowCheckPoint() {
// nop if we know overflow was already checked // nop if we know overflow was already checked
if d.overflowCheck.checked { if d.overflowCheck.checked {
...@@ -645,11 +643,7 @@ func (d *decoder) genSlice1(assignto string, typ types.Type) { ...@@ -645,11 +643,7 @@ func (d *decoder) genSlice1(assignto string, typ types.Type) {
d.emit("{") d.emit("{")
d.genBasic("l:", types.Typ[types.Uint32], nil) d.genBasic("l:", types.Typ[types.Uint32], nil)
// XXX vvv = resetPos but with nread += ... + l d.resetPos()
// XXX -> resetPos("l") ?
d.emit("data = data[%v:]", d.n)
//d.emit("%v += %v + l", d.var_("nread"), d.n)
d.n = 0
d.overflowCheckPoint() d.overflowCheckPoint()
d.overflowCheck.AddExpr("l") d.overflowCheck.AddExpr("l")
...@@ -750,15 +744,7 @@ func (d *decoder) genSlice(assignto string, typ *types.Slice, obj types.Object) ...@@ -750,15 +744,7 @@ func (d *decoder) genSlice(assignto string, typ *types.Slice, obj types.Object)
codegenType("(*a)", typ.Elem(), obj, d) codegenType("(*a)", typ.Elem(), obj, d)
// d.resetPos() with nread update optionally skipped d.resetPos()
// XXX ^^^ criteria to skip is overflowCheck.Checked
if d.n != 0 {
d.emit("data = data[%v:]", d.n)
//if !elemFixed {
// d.emit("%v += %v", d.var_("nread"), d.n)
//}
d.n = 0
}
d.emit("}") d.emit("}")
d.overflowCheckPoint() d.overflowCheckPoint()
...@@ -866,14 +852,7 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) { ...@@ -866,14 +852,7 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) {
d.emit("m[key] = v") d.emit("m[key] = v")
} }
// d.resetPos() with nread update optionally skipped d.resetPos()
if d.n != 0 {
d.emit("data = data[%v:]", d.n)
//if !itemFixed {
// d.emit("%v += %v", d.var_("nread"), d.n)
//}
d.n = 0
}
d.emit("}") d.emit("}")
d.emit("}") d.emit("}")
......
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