Commit ce695ff1 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent dbfa81a6
......@@ -1007,10 +1007,7 @@ func (p *AnswerLockedTransactions) NEOEncodedLen() int {
l := uint32(len(p.TidDict))
_ = l
size += 4
for key := range p.TidDict {
_ = key
size += 16
}
size += l * 16
}
return int(size) + 0
}
......@@ -2758,10 +2755,7 @@ func (p *AnswerObjectUndoSerial) NEOEncodedLen() int {
l := uint32(len(p.ObjectTIDDict))
_ = l
size += 4
for key := range p.ObjectTIDDict {
_ = key
size += 25
}
size += l * 25
}
return int(size) + 0
}
......@@ -2966,10 +2960,7 @@ func (p *CheckReplicas) NEOEncodedLen() int {
l := uint32(len(p.PartitionDict))
_ = l
size += 4
for key := range p.PartitionDict {
_ = key
size += 8
}
size += l * 8
}
return int(size) + 16
}
......
......@@ -407,7 +407,8 @@ func (e *encoder) genMap(path string, typ *types.Map, obj types.Object) {
e.emit("size += %v", e.n)
}
e.n = 0
// TODO if size(item)==const - size update in one go
keySize, keyFixed := typeSizeFixed(typ.Key())
elemSize, elemFixed := typeSizeFixed(typ.Elem())
if !e.SizeOnly {
// output keys in sorted order on the wire
// (easier for debugging & deterministic for testing)
......@@ -417,9 +418,14 @@ func (e *encoder) genMap(path string, typ *types.Map, obj types.Object) {
e.emit("}")
e.emit("sort.Slice(keyv, func (i, j int) bool { return keyv[i] < keyv[j] })")
e.emit("for _, key := range keyv {")
} else {
if keyFixed && elemFixed {
e.emit("size += l * %v", keySize + elemSize)
} else {
e.emit("for key := range %s {", path)
}
}
if !(e.SizeOnly && keyFixed && elemFixed) {
codegenType("key", typ.Key(), obj, e)
codegenType(fmt.Sprintf("%s[key]", path), typ.Elem(), obj, e)
if !e.SizeOnly {
......@@ -429,6 +435,7 @@ func (e *encoder) genMap(path string, typ *types.Map, obj types.Object) {
e.emit("size += %v", e.n)
}
e.emit("}")
}
// XXX vvv ?
e.emit("}")
e.n = 0
......
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