Commit f24296e3 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 2d7a1229
......@@ -170,10 +170,7 @@ overflow:
func (p *XXXTest) NEOEncodedLen() int {
var size int
for key := range p.Zzz {
for key := range p.Zzz[key] {
size += len(p.Zzz[key][key])
}
size += len(p.Zzz[key]) * 8
size += len(p.Zzz[key])
}
return 12 + len(p.Zzz)*8 + size
}
......@@ -196,26 +193,12 @@ func (p *XXXTest) NEOEncode(data []byte) {
l := uint32(len(p.Zzz[key]))
binary.BigEndian.PutUint32(data[4:], l)
data = data[8:]
keyv := make([]int32, 0, l)
for key := range p.Zzz[key] {
keyv = append(keyv, key)
}
sort.Slice(keyv, func(i, j int) bool { return keyv[i] < keyv[j] })
for _, key := range keyv {
binary.BigEndian.PutUint32(data[0:], uint32(key))
{
l := uint32(len(p.Zzz[key][key]))
binary.BigEndian.PutUint32(data[4:], l)
data = data[8:]
copy(data, p.Zzz[key][key])
copy(data, p.Zzz[key])
data = data[l:]
}
data = data[0:]
}
}
data = data[0:]
}
}
}
func (p *XXXTest) NEODecode(data []byte) (int, error) {
......@@ -229,20 +212,8 @@ func (p *XXXTest) NEODecode(data []byte) (int, error) {
l := binary.BigEndian.Uint32(data[8:])
data = data[12:]
nread += 12
p.Zzz = make(map[int32]map[int32]string, l)
p.Zzz = make(map[int32]string, l)
m := p.Zzz
for i := 0; uint32(i) < l; i++ {
if uint32(len(data)) < 8 {
goto overflow
}
key := int32(binary.BigEndian.Uint32(data[0:]))
var v map[int32]string
{
l := binary.BigEndian.Uint32(data[4:])
data = data[8:]
nread += 8
v = make(map[int32]string, l)
m := v
for i := 0; uint32(i) < l; i++ {
if uint32(len(data)) < 8 {
goto overflow
......@@ -260,9 +231,6 @@ func (p *XXXTest) NEODecode(data []byte) (int, error) {
}
}
}
m[key] = v
}
}
return 0 + int(nread), nil
overflow:
......
......@@ -198,7 +198,7 @@ type RowInfo struct {
type XXXTest struct {
qqq uint32
aaa uint32
Zzz map[int32]map[int32]string
Zzz map[int32]string
}
......
......@@ -745,7 +745,6 @@ func (e *encoder) genMap(path string, typ *types.Map, obj types.Object) {
codegenType(fmt.Sprintf("%s[key]", path), typ.Elem(), obj, e)
e.emit("data = data[%v:]", e.n) // XXX wrt map of map?
e.emit("}")
// XXX vvv ?
e.emit("}")
e.n = 0
}
......@@ -782,7 +781,6 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) {
switch typ.Elem().Underlying().(type) {
// basic types can be directly assigned to map entry
case *types.Basic:
// XXX handle string
codegenType("m[key]", typ.Elem(), obj, d)
// otherwise assign via temporary
......@@ -795,7 +793,7 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) {
// d.resetPos() with nread update optionally skipped
if d.n != 0 {
d.emit("data = data[%v:]", d.n)
if !elemFixed {
if !itemFixed {
d.emit("%v += %v", d.var_("nread"), d.n)
}
d.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