Commit ce695ff1 authored by Kirill Smelkov's avatar Kirill Smelkov

.

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