Commit aa902401 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent cdc5f8f4
...@@ -198,6 +198,12 @@ notfixed: ...@@ -198,6 +198,12 @@ notfixed:
return 0, false return 0, false
} }
// does a type have fixed wire size == 1 ?
func typeSizeFixed1(typ types.Type) bool {
wireSize, _ := typeSizeFixed(typ)
return wireSize == 1
}
// Buffer + bell & whistles // Buffer + bell & whistles
type Buffer struct { type Buffer struct {
...@@ -808,9 +814,8 @@ func codegenType(path string, typ types.Type, obj types.Object, codegen CodecCod ...@@ -808,9 +814,8 @@ func codegenType(path string, typ types.Type, obj types.Object, codegen CodecCod
} }
case *types.Array: case *types.Array:
elemSize, _ := typeSizeFixed(u.Elem())
// [...]byte or [...]uint8 - just straight copy // [...]byte or [...]uint8 - just straight copy
if false && elemSize == 1 { if false && typeSizeFixed1(u.Elem()) {
//codegen.genStrBytes(path+"[:]") // FIXME //codegen.genStrBytes(path+"[:]") // FIXME
codegen.genSlice1(path, u) // FIXME codegen.genSlice1(path, u) // FIXME
} else { } else {
...@@ -821,7 +826,7 @@ func codegenType(path string, typ types.Type, obj types.Object, codegen CodecCod ...@@ -821,7 +826,7 @@ func codegenType(path string, typ types.Type, obj types.Object, codegen CodecCod
} }
case *types.Slice: case *types.Slice:
if elemSize, _ := typeSizeFixed(u.Elem()); elemSize == 1 { if typeSizeFixed1(u.Elem()) {
codegen.genSlice1(path, u) codegen.genSlice1(path, u)
} else { } else {
codegen.genSlice(path, u, obj) codegen.genSlice(path, u, obj)
......
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