[#111] protogen: Emit slice of messages without a pointer

```
goos: linux
goarch: amd64
pkg: git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs
cpu: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
                                              │      old      │                 new                  │
                                              │    sec/op     │    sec/op     vs base                │
ObjectIDSlice/0_elements/to_grpc_message-8       3.193n ±  2%   3.242n ±  0%   +1.50% (p=0.034 n=10)
ObjectIDSlice/0_elements/from_grpc_message-8     3.197n ±  2%   3.343n ±  1%   +4.57% (p=0.000 n=10)
ObjectIDSlice/0_elements/marshal-8               5.666n ±  3%   5.642n ±  0%   -0.42% (p=0.000 n=10)
ObjectIDSlice/1_elements/to_grpc_message-8       53.10n ±  6%   29.78n ± 12%  -43.92% (p=0.000 n=10)
ObjectIDSlice/1_elements/from_grpc_message-8     28.99n ±  5%   29.77n ±  7%        ~ (p=0.165 n=10)
ObjectIDSlice/1_elements/marshal-8               49.08n ±  7%   50.72n ±  6%        ~ (p=0.218 n=10)
ObjectIDSlice/50_elements/to_grpc_message-8     1652.5n ±  7%   277.2n ±  1%  -83.22% (p=0.000 n=10)
ObjectIDSlice/50_elements/from_grpc_message-8    261.2n ± 11%   226.7n ± 15%  -13.19% (p=0.003 n=10)
ObjectIDSlice/50_elements/marshal-8              1.512µ ±  6%   1.514µ ±  6%        ~ (p=0.955 n=10)
geomean                                          52.15n         39.99n        -23.31%

                                              │      old       │                  new                   │
                                              │      B/op      │     B/op      vs base                  │
ObjectIDSlice/0_elements/to_grpc_message-8        0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
ObjectIDSlice/0_elements/from_grpc_message-8      0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
ObjectIDSlice/0_elements/marshal-8                0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
ObjectIDSlice/1_elements/to_grpc_message-8        32.00 ± 0%       24.00 ± 0%  -25.00% (p=0.000 n=10)
ObjectIDSlice/1_elements/from_grpc_message-8      24.00 ± 0%       24.00 ± 0%        ~ (p=1.000 n=10) ¹
ObjectIDSlice/1_elements/marshal-8                48.00 ± 0%       48.00 ± 0%        ~ (p=1.000 n=10) ¹
ObjectIDSlice/50_elements/to_grpc_message-8     1.578Ki ± 0%     1.250Ki ± 0%  -20.79% (p=0.000 n=10)
ObjectIDSlice/50_elements/from_grpc_message-8   1.250Ki ± 0%     1.250Ki ± 0%        ~ (p=1.000 n=10) ¹
ObjectIDSlice/50_elements/marshal-8             2.000Ki ± 0%     2.000Ki ± 0%        ~ (p=1.000 n=10) ¹
geomean                                                      ²                  -5.62%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                              │      old      │                 new                  │
                                              │   allocs/op   │ allocs/op   vs base                  │
ObjectIDSlice/0_elements/to_grpc_message-8       0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
ObjectIDSlice/0_elements/from_grpc_message-8     0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
ObjectIDSlice/0_elements/marshal-8               0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
ObjectIDSlice/1_elements/to_grpc_message-8       2.000 ± 0%     1.000 ± 0%  -50.00% (p=0.000 n=10)
ObjectIDSlice/1_elements/from_grpc_message-8     1.000 ± 0%     1.000 ± 0%        ~ (p=1.000 n=10) ¹
ObjectIDSlice/1_elements/marshal-8               1.000 ± 0%     1.000 ± 0%        ~ (p=1.000 n=10) ¹
ObjectIDSlice/50_elements/to_grpc_message-8     51.000 ± 0%     1.000 ± 0%  -98.04% (p=0.000 n=10)
ObjectIDSlice/50_elements/from_grpc_message-8    1.000 ± 0%     1.000 ± 0%        ~ (p=1.000 n=10) ¹
ObjectIDSlice/50_elements/marshal-8              1.000 ± 0%     1.000 ± 0%        ~ (p=1.000 n=10) ¹
geomean                                                     ²               -40.18%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean
```

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-08-27 15:12:31 +03:00
parent a2025376fc
commit 5e1c6a908f
26 changed files with 461 additions and 547 deletions

View file

@ -187,28 +187,26 @@ func (f *HeaderFilter) FromGRPCMessage(m grpc.Message) error {
return nil
}
func HeaderFiltersToGRPC(fs []HeaderFilter) (res []*acl.EACLRecord_Filter) {
func HeaderFiltersToGRPC(fs []HeaderFilter) (res []acl.EACLRecord_Filter) {
if fs != nil {
res = make([]*acl.EACLRecord_Filter, 0, len(fs))
res = make([]acl.EACLRecord_Filter, 0, len(fs))
for i := range fs {
res = append(res, fs[i].ToGRPCMessage().(*acl.EACLRecord_Filter))
res = append(res, *fs[i].ToGRPCMessage().(*acl.EACLRecord_Filter))
}
}
return
}
func HeaderFiltersFromGRPC(fs []*acl.EACLRecord_Filter) (res []HeaderFilter, err error) {
func HeaderFiltersFromGRPC(fs []acl.EACLRecord_Filter) (res []HeaderFilter, err error) {
if fs != nil {
res = make([]HeaderFilter, len(fs))
for i := range fs {
if fs[i] != nil {
err = res[i].FromGRPCMessage(fs[i])
if err != nil {
return
}
err = res[i].FromGRPCMessage(&fs[i])
if err != nil {
return
}
}
}
@ -241,28 +239,26 @@ func (t *Target) FromGRPCMessage(m grpc.Message) error {
return nil
}
func TargetsToGRPC(ts []Target) (res []*acl.EACLRecord_Target) {
func TargetsToGRPC(ts []Target) (res []acl.EACLRecord_Target) {
if ts != nil {
res = make([]*acl.EACLRecord_Target, 0, len(ts))
res = make([]acl.EACLRecord_Target, 0, len(ts))
for i := range ts {
res = append(res, ts[i].ToGRPCMessage().(*acl.EACLRecord_Target))
res = append(res, *ts[i].ToGRPCMessage().(*acl.EACLRecord_Target))
}
}
return
}
func TargetsFromGRPC(fs []*acl.EACLRecord_Target) (res []Target, err error) {
func TargetsFromGRPC(fs []acl.EACLRecord_Target) (res []Target, err error) {
if fs != nil {
res = make([]Target, len(fs))
for i := range fs {
if fs[i] != nil {
err = res[i].FromGRPCMessage(fs[i])
if err != nil {
return
}
err = res[i].FromGRPCMessage(&fs[i])
if err != nil {
return
}
}
}
@ -309,28 +305,26 @@ func (r *Record) FromGRPCMessage(m grpc.Message) error {
return nil
}
func RecordsToGRPC(ts []Record) (res []*acl.EACLRecord) {
func RecordsToGRPC(ts []Record) (res []acl.EACLRecord) {
if ts != nil {
res = make([]*acl.EACLRecord, 0, len(ts))
res = make([]acl.EACLRecord, 0, len(ts))
for i := range ts {
res = append(res, ts[i].ToGRPCMessage().(*acl.EACLRecord))
res = append(res, *ts[i].ToGRPCMessage().(*acl.EACLRecord))
}
}
return
}
func RecordsFromGRPC(fs []*acl.EACLRecord) (res []Record, err error) {
func RecordsFromGRPC(fs []acl.EACLRecord) (res []Record, err error) {
if fs != nil {
res = make([]Record, len(fs))
for i := range fs {
if fs[i] != nil {
err = res[i].FromGRPCMessage(fs[i])
if err != nil {
return
}
err = res[i].FromGRPCMessage(&fs[i])
if err != nil {
return
}
}
}
@ -429,9 +423,9 @@ func (c *APEOverride) ToGRPCMessage() grpc.Message {
m.SetTarget(c.target.ToGRPCMessage().(*apeGRPC.ChainTarget))
if len(c.chains) > 0 {
apeChains := make([]*apeGRPC.Chain, len(c.chains))
apeChains := make([]apeGRPC.Chain, len(c.chains))
for i := range c.chains {
apeChains[i] = c.chains[i].ToGRPCMessage().(*apeGRPC.Chain)
apeChains[i] = *c.chains[i].ToGRPCMessage().(*apeGRPC.Chain)
}
m.SetChains(apeChains)
}
@ -459,7 +453,7 @@ func (c *APEOverride) FromGRPCMessage(m grpc.Message) error {
c.chains = make([]*ape.Chain, len(apeChains))
for i := range apeChains {
c.chains[i] = new(ape.Chain)
if err := c.chains[i].FromGRPCMessage(apeChains[i]); err != nil {
if err := c.chains[i].FromGRPCMessage(&apeChains[i]); err != nil {
return err
}
}

View file

@ -657,10 +657,10 @@ func (x *EACLRecord_Target) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
type EACLRecord struct {
Operation Operation `json:"operation"`
Action Action `json:"action"`
Filters []*EACLRecord_Filter `json:"filters"`
Targets []*EACLRecord_Target `json:"targets"`
Operation Operation `json:"operation"`
Action Action `json:"action"`
Filters []EACLRecord_Filter `json:"filters"`
Targets []EACLRecord_Target `json:"targets"`
}
var (
@ -680,10 +680,10 @@ func (x *EACLRecord) StableSize() (size int) {
size += proto.EnumSize(1, int32(x.Operation))
size += proto.EnumSize(2, int32(x.Action))
for i := range x.Filters {
size += proto.NestedStructureSize(3, x.Filters[i])
size += proto.NestedStructureSizeUnchecked(3, &x.Filters[i])
}
for i := range x.Targets {
size += proto.NestedStructureSize(4, x.Targets[i])
size += proto.NestedStructureSizeUnchecked(4, &x.Targets[i])
}
return size
}
@ -708,14 +708,10 @@ func (x *EACLRecord) EmitProtobuf(mm *easyproto.MessageMarshaler) {
mm.AppendInt32(2, int32(x.Action))
}
for i := range x.Filters {
if x.Filters[i] != nil {
x.Filters[i].EmitProtobuf(mm.AppendMessage(3))
}
x.Filters[i].EmitProtobuf(mm.AppendMessage(3))
}
for i := range x.Targets {
if x.Targets[i] != nil {
x.Targets[i].EmitProtobuf(mm.AppendMessage(4))
}
x.Targets[i].EmitProtobuf(mm.AppendMessage(4))
}
}
@ -745,8 +741,8 @@ func (x *EACLRecord) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Filters")
}
x.Filters = append(x.Filters, new(EACLRecord_Filter))
ff := x.Filters[len(x.Filters)-1]
x.Filters = append(x.Filters, EACLRecord_Filter{})
ff := &x.Filters[len(x.Filters)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -755,8 +751,8 @@ func (x *EACLRecord) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Targets")
}
x.Targets = append(x.Targets, new(EACLRecord_Target))
ff := x.Targets[len(x.Targets)-1]
x.Targets = append(x.Targets, EACLRecord_Target{})
ff := &x.Targets[len(x.Targets)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -782,22 +778,22 @@ func (x *EACLRecord) GetAction() Action {
func (x *EACLRecord) SetAction(v Action) {
x.Action = v
}
func (x *EACLRecord) GetFilters() []*EACLRecord_Filter {
func (x *EACLRecord) GetFilters() []EACLRecord_Filter {
if x != nil {
return x.Filters
}
return nil
}
func (x *EACLRecord) SetFilters(v []*EACLRecord_Filter) {
func (x *EACLRecord) SetFilters(v []EACLRecord_Filter) {
x.Filters = v
}
func (x *EACLRecord) GetTargets() []*EACLRecord_Target {
func (x *EACLRecord) GetTargets() []EACLRecord_Target {
if x != nil {
return x.Targets
}
return nil
}
func (x *EACLRecord) SetTargets(v []*EACLRecord_Target) {
func (x *EACLRecord) SetTargets(v []EACLRecord_Target) {
x.Targets = v
}
@ -921,11 +917,11 @@ func (x *EACLRecord) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "filters":
{
var f *EACLRecord_Filter
var list []*EACLRecord_Filter
var f EACLRecord_Filter
var list []EACLRecord_Filter
in.Delim('[')
for !in.IsDelim(']') {
f = new(EACLRecord_Filter)
f = EACLRecord_Filter{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -935,11 +931,11 @@ func (x *EACLRecord) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "targets":
{
var f *EACLRecord_Target
var list []*EACLRecord_Target
var f EACLRecord_Target
var list []EACLRecord_Target
in.Delim('[')
for !in.IsDelim(']') {
f = new(EACLRecord_Target)
f = EACLRecord_Target{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -959,7 +955,7 @@ func (x *EACLRecord) UnmarshalEasyJSON(in *jlexer.Lexer) {
type EACLTable struct {
Version *grpc.Version `json:"version"`
ContainerId *grpc.ContainerID `json:"containerID"`
Records []*EACLRecord `json:"records"`
Records []EACLRecord `json:"records"`
}
var (
@ -979,7 +975,7 @@ func (x *EACLTable) StableSize() (size int) {
size += proto.NestedStructureSize(1, x.Version)
size += proto.NestedStructureSize(2, x.ContainerId)
for i := range x.Records {
size += proto.NestedStructureSize(3, x.Records[i])
size += proto.NestedStructureSizeUnchecked(3, &x.Records[i])
}
return size
}
@ -1004,9 +1000,7 @@ func (x *EACLTable) EmitProtobuf(mm *easyproto.MessageMarshaler) {
x.ContainerId.EmitProtobuf(mm.AppendMessage(2))
}
for i := range x.Records {
if x.Records[i] != nil {
x.Records[i].EmitProtobuf(mm.AppendMessage(3))
}
x.Records[i].EmitProtobuf(mm.AppendMessage(3))
}
}
@ -1042,8 +1036,8 @@ func (x *EACLTable) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Records")
}
x.Records = append(x.Records, new(EACLRecord))
ff := x.Records[len(x.Records)-1]
x.Records = append(x.Records, EACLRecord{})
ff := &x.Records[len(x.Records)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -1069,13 +1063,13 @@ func (x *EACLTable) GetContainerId() *grpc.ContainerID {
func (x *EACLTable) SetContainerId(v *grpc.ContainerID) {
x.ContainerId = v
}
func (x *EACLTable) GetRecords() []*EACLRecord {
func (x *EACLTable) GetRecords() []EACLRecord {
if x != nil {
return x.Records
}
return nil
}
func (x *EACLTable) SetRecords(v []*EACLRecord) {
func (x *EACLTable) SetRecords(v []EACLRecord) {
x.Records = v
}
@ -1157,11 +1151,11 @@ func (x *EACLTable) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "records":
{
var f *EACLRecord
var list []*EACLRecord
var f EACLRecord
var list []EACLRecord
in.Delim('[')
for !in.IsDelim(']') {
f = new(EACLRecord)
f = EACLRecord{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -1371,7 +1365,7 @@ func (x *BearerToken_Body_TokenLifetime) UnmarshalEasyJSON(in *jlexer.Lexer) {
type BearerToken_Body_APEOverride struct {
Target *grpc1.ChainTarget `json:"target"`
Chains []*grpc1.Chain `json:"chains"`
Chains []grpc1.Chain `json:"chains"`
}
var (
@ -1390,7 +1384,7 @@ func (x *BearerToken_Body_APEOverride) StableSize() (size int) {
}
size += proto.NestedStructureSize(1, x.Target)
for i := range x.Chains {
size += proto.NestedStructureSize(2, x.Chains[i])
size += proto.NestedStructureSizeUnchecked(2, &x.Chains[i])
}
return size
}
@ -1412,9 +1406,7 @@ func (x *BearerToken_Body_APEOverride) EmitProtobuf(mm *easyproto.MessageMarshal
x.Target.EmitProtobuf(mm.AppendMessage(1))
}
for i := range x.Chains {
if x.Chains[i] != nil {
x.Chains[i].EmitProtobuf(mm.AppendMessage(2))
}
x.Chains[i].EmitProtobuf(mm.AppendMessage(2))
}
}
@ -1441,8 +1433,8 @@ func (x *BearerToken_Body_APEOverride) UnmarshalProtobuf(src []byte) (err error)
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Chains")
}
x.Chains = append(x.Chains, new(grpc1.Chain))
ff := x.Chains[len(x.Chains)-1]
x.Chains = append(x.Chains, grpc1.Chain{})
ff := &x.Chains[len(x.Chains)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -1459,13 +1451,13 @@ func (x *BearerToken_Body_APEOverride) GetTarget() *grpc1.ChainTarget {
func (x *BearerToken_Body_APEOverride) SetTarget(v *grpc1.ChainTarget) {
x.Target = v
}
func (x *BearerToken_Body_APEOverride) GetChains() []*grpc1.Chain {
func (x *BearerToken_Body_APEOverride) GetChains() []grpc1.Chain {
if x != nil {
return x.Chains
}
return nil
}
func (x *BearerToken_Body_APEOverride) SetChains(v []*grpc1.Chain) {
func (x *BearerToken_Body_APEOverride) SetChains(v []grpc1.Chain) {
x.Chains = v
}
@ -1535,11 +1527,11 @@ func (x *BearerToken_Body_APEOverride) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "chains":
{
var f *grpc1.Chain
var list []*grpc1.Chain
var f grpc1.Chain
var list []grpc1.Chain
in.Delim('[')
for !in.IsDelim(']') {
f = new(grpc1.Chain)
f = grpc1.Chain{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()

View file

@ -296,9 +296,9 @@ func (respBody *ListChainsResponseBody) ToGRPCMessage() grpc.Message {
if respBody != nil {
respBodygrpc = new(apemanager.ListChainsResponse_Body)
chainsgrpc := make([]*apeGRPC.Chain, 0, len(respBody.GetChains()))
chainsgrpc := make([]apeGRPC.Chain, 0, len(respBody.GetChains()))
for _, chain := range respBody.GetChains() {
chainsgrpc = append(chainsgrpc, chain.ToGRPCMessage().(*apeGRPC.Chain))
chainsgrpc = append(chainsgrpc, *chain.ToGRPCMessage().(*apeGRPC.Chain))
}
respBodygrpc.SetChains(chainsgrpc)
@ -317,7 +317,7 @@ func (respBody *ListChainsResponseBody) FromGRPCMessage(m grpc.Message) error {
for _, chaingrpc := range respBodygrpc.GetChains() {
chain := new(ape.Chain)
if err := chain.FromGRPCMessage(chaingrpc); err != nil {
if err := chain.FromGRPCMessage(&chaingrpc); err != nil {
return err
}
chains = append(chains, chain)

View file

@ -1810,7 +1810,7 @@ func (x *ListChainsRequest) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
type ListChainsResponse_Body struct {
Chains []*grpc.Chain `json:"chains"`
Chains []grpc.Chain `json:"chains"`
}
var (
@ -1828,7 +1828,7 @@ func (x *ListChainsResponse_Body) StableSize() (size int) {
return 0
}
for i := range x.Chains {
size += proto.NestedStructureSize(1, x.Chains[i])
size += proto.NestedStructureSizeUnchecked(1, &x.Chains[i])
}
return size
}
@ -1847,9 +1847,7 @@ func (x *ListChainsResponse_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) {
return
}
for i := range x.Chains {
if x.Chains[i] != nil {
x.Chains[i].EmitProtobuf(mm.AppendMessage(1))
}
x.Chains[i].EmitProtobuf(mm.AppendMessage(1))
}
}
@ -1867,8 +1865,8 @@ func (x *ListChainsResponse_Body) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Chains")
}
x.Chains = append(x.Chains, new(grpc.Chain))
ff := x.Chains[len(x.Chains)-1]
x.Chains = append(x.Chains, grpc.Chain{})
ff := &x.Chains[len(x.Chains)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -1876,13 +1874,13 @@ func (x *ListChainsResponse_Body) UnmarshalProtobuf(src []byte) (err error) {
}
return nil
}
func (x *ListChainsResponse_Body) GetChains() []*grpc.Chain {
func (x *ListChainsResponse_Body) GetChains() []grpc.Chain {
if x != nil {
return x.Chains
}
return nil
}
func (x *ListChainsResponse_Body) SetChains(v []*grpc.Chain) {
func (x *ListChainsResponse_Body) SetChains(v []grpc.Chain) {
x.Chains = v
}
@ -1940,11 +1938,11 @@ func (x *ListChainsResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch key {
case "chains":
{
var f *grpc.Chain
var list []*grpc.Chain
var f grpc.Chain
var list []grpc.Chain
in.Delim('[')
for !in.IsDelim(']') {
f = new(grpc.Chain)
f = grpc.Chain{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()

View file

@ -39,28 +39,26 @@ func (a *Attribute) FromGRPCMessage(m grpc.Message) error {
return nil
}
func AttributesToGRPC(xs []Attribute) (res []*container.Container_Attribute) {
func AttributesToGRPC(xs []Attribute) (res []container.Container_Attribute) {
if xs != nil {
res = make([]*container.Container_Attribute, 0, len(xs))
res = make([]container.Container_Attribute, 0, len(xs))
for i := range xs {
res = append(res, xs[i].ToGRPCMessage().(*container.Container_Attribute))
res = append(res, *xs[i].ToGRPCMessage().(*container.Container_Attribute))
}
}
return
}
func AttributesFromGRPC(xs []*container.Container_Attribute) (res []Attribute, err error) {
func AttributesFromGRPC(xs []container.Container_Attribute) (res []Attribute, err error) {
if xs != nil {
res = make([]Attribute, len(xs))
for i := range xs {
if xs[i] != nil {
err = res[i].FromGRPCMessage(xs[i])
if err != nil {
return
}
err = res[i].FromGRPCMessage(&xs[i])
if err != nil {
return
}
}
}

View file

@ -2597,7 +2597,7 @@ func (x *ListRequest) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
type ListResponse_Body struct {
ContainerIds []*grpc.ContainerID `json:"containerIds"`
ContainerIds []grpc.ContainerID `json:"containerIds"`
}
var (
@ -2615,7 +2615,7 @@ func (x *ListResponse_Body) StableSize() (size int) {
return 0
}
for i := range x.ContainerIds {
size += proto.NestedStructureSize(1, x.ContainerIds[i])
size += proto.NestedStructureSizeUnchecked(1, &x.ContainerIds[i])
}
return size
}
@ -2634,9 +2634,7 @@ func (x *ListResponse_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) {
return
}
for i := range x.ContainerIds {
if x.ContainerIds[i] != nil {
x.ContainerIds[i].EmitProtobuf(mm.AppendMessage(1))
}
x.ContainerIds[i].EmitProtobuf(mm.AppendMessage(1))
}
}
@ -2654,8 +2652,8 @@ func (x *ListResponse_Body) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "ContainerIds")
}
x.ContainerIds = append(x.ContainerIds, new(grpc.ContainerID))
ff := x.ContainerIds[len(x.ContainerIds)-1]
x.ContainerIds = append(x.ContainerIds, grpc.ContainerID{})
ff := &x.ContainerIds[len(x.ContainerIds)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -2663,13 +2661,13 @@ func (x *ListResponse_Body) UnmarshalProtobuf(src []byte) (err error) {
}
return nil
}
func (x *ListResponse_Body) GetContainerIds() []*grpc.ContainerID {
func (x *ListResponse_Body) GetContainerIds() []grpc.ContainerID {
if x != nil {
return x.ContainerIds
}
return nil
}
func (x *ListResponse_Body) SetContainerIds(v []*grpc.ContainerID) {
func (x *ListResponse_Body) SetContainerIds(v []grpc.ContainerID) {
x.ContainerIds = v
}
@ -2727,11 +2725,11 @@ func (x *ListResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch key {
case "containerIds":
{
var f *grpc.ContainerID
var list []*grpc.ContainerID
var f grpc.ContainerID
var list []grpc.ContainerID
in.Delim('[')
for !in.IsDelim(']') {
f = new(grpc.ContainerID)
f = grpc.ContainerID{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()

View file

@ -180,7 +180,7 @@ type Container struct {
OwnerId *grpc.OwnerID `json:"ownerID"`
Nonce []byte `json:"nonce"`
BasicAcl uint32 `json:"basicACL"`
Attributes []*Container_Attribute `json:"attributes"`
Attributes []Container_Attribute `json:"attributes"`
PlacementPolicy *grpc1.PlacementPolicy `json:"placementPolicy"`
}
@ -203,7 +203,7 @@ func (x *Container) StableSize() (size int) {
size += proto.BytesSize(3, x.Nonce)
size += proto.UInt32Size(4, x.BasicAcl)
for i := range x.Attributes {
size += proto.NestedStructureSize(5, x.Attributes[i])
size += proto.NestedStructureSizeUnchecked(5, &x.Attributes[i])
}
size += proto.NestedStructureSize(6, x.PlacementPolicy)
return size
@ -235,9 +235,7 @@ func (x *Container) EmitProtobuf(mm *easyproto.MessageMarshaler) {
mm.AppendUint32(4, x.BasicAcl)
}
for i := range x.Attributes {
if x.Attributes[i] != nil {
x.Attributes[i].EmitProtobuf(mm.AppendMessage(5))
}
x.Attributes[i].EmitProtobuf(mm.AppendMessage(5))
}
if x.PlacementPolicy != nil {
x.PlacementPolicy.EmitProtobuf(mm.AppendMessage(6))
@ -288,8 +286,8 @@ func (x *Container) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Attributes")
}
x.Attributes = append(x.Attributes, new(Container_Attribute))
ff := x.Attributes[len(x.Attributes)-1]
x.Attributes = append(x.Attributes, Container_Attribute{})
ff := &x.Attributes[len(x.Attributes)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -342,13 +340,13 @@ func (x *Container) GetBasicAcl() uint32 {
func (x *Container) SetBasicAcl(v uint32) {
x.BasicAcl = v
}
func (x *Container) GetAttributes() []*Container_Attribute {
func (x *Container) GetAttributes() []Container_Attribute {
if x != nil {
return x.Attributes
}
return nil
}
func (x *Container) SetAttributes(v []*Container_Attribute) {
func (x *Container) SetAttributes(v []Container_Attribute) {
x.Attributes = v
}
func (x *Container) GetPlacementPolicy() *grpc1.PlacementPolicy {
@ -466,11 +464,11 @@ func (x *Container) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "attributes":
{
var f *Container_Attribute
var list []*Container_Attribute
var f Container_Attribute
var list []Container_Attribute
in.Delim('[')
for !in.IsDelim(']') {
f = new(Container_Attribute)
f = Container_Attribute{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()

View file

@ -15,7 +15,7 @@ import (
)
type Lock struct {
Members []*grpc.ObjectID `json:"members"`
Members []grpc.ObjectID `json:"members"`
}
var (
@ -33,7 +33,7 @@ func (x *Lock) StableSize() (size int) {
return 0
}
for i := range x.Members {
size += proto.NestedStructureSize(1, x.Members[i])
size += proto.NestedStructureSizeUnchecked(1, &x.Members[i])
}
return size
}
@ -52,9 +52,7 @@ func (x *Lock) EmitProtobuf(mm *easyproto.MessageMarshaler) {
return
}
for i := range x.Members {
if x.Members[i] != nil {
x.Members[i].EmitProtobuf(mm.AppendMessage(1))
}
x.Members[i].EmitProtobuf(mm.AppendMessage(1))
}
}
@ -72,8 +70,8 @@ func (x *Lock) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Members")
}
x.Members = append(x.Members, new(grpc.ObjectID))
ff := x.Members[len(x.Members)-1]
x.Members = append(x.Members, grpc.ObjectID{})
ff := &x.Members[len(x.Members)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -81,13 +79,13 @@ func (x *Lock) UnmarshalProtobuf(src []byte) (err error) {
}
return nil
}
func (x *Lock) GetMembers() []*grpc.ObjectID {
func (x *Lock) GetMembers() []grpc.ObjectID {
if x != nil {
return x.Members
}
return nil
}
func (x *Lock) SetMembers(v []*grpc.ObjectID) {
func (x *Lock) SetMembers(v []grpc.ObjectID) {
x.Members = v
}
@ -145,11 +143,11 @@ func (x *Lock) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch key {
case "members":
{
var f *grpc.ObjectID
var list []*grpc.ObjectID
var f grpc.ObjectID
var list []grpc.ObjectID
in.Delim('[')
for !in.IsDelim(']') {
f = new(grpc.ObjectID)
f = grpc.ObjectID{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()

View file

@ -45,28 +45,26 @@ func (f *Filter) FromGRPCMessage(m grpc.Message) error {
return nil
}
func FiltersToGRPC(fs []Filter) (res []*netmap.Filter) {
func FiltersToGRPC(fs []Filter) (res []netmap.Filter) {
if fs != nil {
res = make([]*netmap.Filter, 0, len(fs))
res = make([]netmap.Filter, 0, len(fs))
for i := range fs {
res = append(res, fs[i].ToGRPCMessage().(*netmap.Filter))
res = append(res, *fs[i].ToGRPCMessage().(*netmap.Filter))
}
}
return
}
func FiltersFromGRPC(fs []*netmap.Filter) (res []Filter, err error) {
func FiltersFromGRPC(fs []netmap.Filter) (res []Filter, err error) {
if fs != nil {
res = make([]Filter, len(fs))
for i := range fs {
if fs[i] != nil {
err = res[i].FromGRPCMessage(fs[i])
if err != nil {
return
}
err = res[i].FromGRPCMessage(&fs[i])
if err != nil {
return
}
}
}
@ -105,28 +103,26 @@ func (s *Selector) FromGRPCMessage(m grpc.Message) error {
return nil
}
func SelectorsToGRPC(ss []Selector) (res []*netmap.Selector) {
func SelectorsToGRPC(ss []Selector) (res []netmap.Selector) {
if ss != nil {
res = make([]*netmap.Selector, 0, len(ss))
res = make([]netmap.Selector, 0, len(ss))
for i := range ss {
res = append(res, ss[i].ToGRPCMessage().(*netmap.Selector))
res = append(res, *ss[i].ToGRPCMessage().(*netmap.Selector))
}
}
return
}
func SelectorsFromGRPC(ss []*netmap.Selector) (res []Selector, err error) {
func SelectorsFromGRPC(ss []netmap.Selector) (res []Selector, err error) {
if ss != nil {
res = make([]Selector, len(ss))
for i := range ss {
if ss[i] != nil {
err = res[i].FromGRPCMessage(ss[i])
if err != nil {
return
}
err = res[i].FromGRPCMessage(&ss[i])
if err != nil {
return
}
}
}
@ -163,28 +159,26 @@ func (r *Replica) FromGRPCMessage(m grpc.Message) error {
return nil
}
func ReplicasToGRPC(rs []Replica) (res []*netmap.Replica) {
func ReplicasToGRPC(rs []Replica) (res []netmap.Replica) {
if rs != nil {
res = make([]*netmap.Replica, 0, len(rs))
res = make([]netmap.Replica, 0, len(rs))
for i := range rs {
res = append(res, rs[i].ToGRPCMessage().(*netmap.Replica))
res = append(res, *rs[i].ToGRPCMessage().(*netmap.Replica))
}
}
return
}
func ReplicasFromGRPC(rs []*netmap.Replica) (res []Replica, err error) {
func ReplicasFromGRPC(rs []netmap.Replica) (res []Replica, err error) {
if rs != nil {
res = make([]Replica, len(rs))
for i := range rs {
if rs[i] != nil {
err = res[i].FromGRPCMessage(rs[i])
if err != nil {
return
}
err = res[i].FromGRPCMessage(&rs[i])
if err != nil {
return
}
}
}
@ -289,28 +283,26 @@ func (a *Attribute) FromGRPCMessage(m grpc.Message) error {
return nil
}
func AttributesToGRPC(as []Attribute) (res []*netmap.NodeInfo_Attribute) {
func AttributesToGRPC(as []Attribute) (res []netmap.NodeInfo_Attribute) {
if as != nil {
res = make([]*netmap.NodeInfo_Attribute, 0, len(as))
res = make([]netmap.NodeInfo_Attribute, 0, len(as))
for i := range as {
res = append(res, as[i].ToGRPCMessage().(*netmap.NodeInfo_Attribute))
res = append(res, *as[i].ToGRPCMessage().(*netmap.NodeInfo_Attribute))
}
}
return
}
func AttributesFromGRPC(as []*netmap.NodeInfo_Attribute) (res []Attribute, err error) {
func AttributesFromGRPC(as []netmap.NodeInfo_Attribute) (res []Attribute, err error) {
if as != nil {
res = make([]Attribute, len(as))
for i := range as {
if as[i] != nil {
err = res[i].FromGRPCMessage(as[i])
if err != nil {
return
}
err = res[i].FromGRPCMessage(&as[i])
if err != nil {
return
}
}
}
@ -528,13 +520,13 @@ func (x *NetworkConfig) ToGRPCMessage() grpc.Message {
if x != nil {
m = new(netmap.NetworkConfig)
var ps []*netmap.NetworkConfig_Parameter
var ps []netmap.NetworkConfig_Parameter
if ln := len(x.ps); ln > 0 {
ps = make([]*netmap.NetworkConfig_Parameter, 0, ln)
ps = make([]netmap.NetworkConfig_Parameter, 0, ln)
for i := 0; i < ln; i++ {
ps = append(ps, x.ps[i].ToGRPCMessage().(*netmap.NetworkConfig_Parameter))
ps = append(ps, *x.ps[i].ToGRPCMessage().(*netmap.NetworkConfig_Parameter))
}
}
@ -561,10 +553,8 @@ func (x *NetworkConfig) FromGRPCMessage(m grpc.Message) error {
ps = make([]NetworkParameter, ln)
for i := 0; i < ln; i++ {
if psV2[i] != nil {
if err := ps[i].FromGRPCMessage(psV2[i]); err != nil {
return err
}
if err := ps[i].FromGRPCMessage(&psV2[i]); err != nil {
return err
}
}
}
@ -756,10 +746,10 @@ func (x *NetMap) ToGRPCMessage() grpc.Message {
m.SetEpoch(x.epoch)
if x.nodes != nil {
nodes := make([]*netmap.NodeInfo, len(x.nodes))
nodes := make([]netmap.NodeInfo, len(x.nodes))
for i := range x.nodes {
nodes[i] = x.nodes[i].ToGRPCMessage().(*netmap.NodeInfo)
nodes[i] = *x.nodes[i].ToGRPCMessage().(*netmap.NodeInfo)
}
m.SetNodes(nodes)
@ -784,7 +774,7 @@ func (x *NetMap) FromGRPCMessage(m grpc.Message) error {
x.nodes = make([]NodeInfo, len(nodes))
for i := range nodes {
err = x.nodes[i].FromGRPCMessage(nodes[i])
err = x.nodes[i].FromGRPCMessage(&nodes[i])
if err != nil {
return err
}

View file

@ -113,7 +113,7 @@ type Filter struct {
Key string `json:"key"`
Op Operation `json:"op"`
Value string `json:"value"`
Filters []*Filter `json:"filters"`
Filters []Filter `json:"filters"`
}
var (
@ -135,7 +135,7 @@ func (x *Filter) StableSize() (size int) {
size += proto.EnumSize(3, int32(x.Op))
size += proto.StringSize(4, x.Value)
for i := range x.Filters {
size += proto.NestedStructureSize(5, x.Filters[i])
size += proto.NestedStructureSizeUnchecked(5, &x.Filters[i])
}
return size
}
@ -166,9 +166,7 @@ func (x *Filter) EmitProtobuf(mm *easyproto.MessageMarshaler) {
mm.AppendString(4, x.Value)
}
for i := range x.Filters {
if x.Filters[i] != nil {
x.Filters[i].EmitProtobuf(mm.AppendMessage(5))
}
x.Filters[i].EmitProtobuf(mm.AppendMessage(5))
}
}
@ -210,8 +208,8 @@ func (x *Filter) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Filters")
}
x.Filters = append(x.Filters, new(Filter))
ff := x.Filters[len(x.Filters)-1]
x.Filters = append(x.Filters, Filter{})
ff := &x.Filters[len(x.Filters)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -255,13 +253,13 @@ func (x *Filter) GetValue() string {
func (x *Filter) SetValue(v string) {
x.Value = v
}
func (x *Filter) GetFilters() []*Filter {
func (x *Filter) GetFilters() []Filter {
if x != nil {
return x.Filters
}
return nil
}
func (x *Filter) SetFilters(v []*Filter) {
func (x *Filter) SetFilters(v []Filter) {
x.Filters = v
}
@ -379,11 +377,11 @@ func (x *Filter) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "filters":
{
var f *Filter
var list []*Filter
var f Filter
var list []Filter
in.Delim('[')
for !in.IsDelim(']') {
f = new(Filter)
f = Filter{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -892,11 +890,11 @@ func (x *Replica) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
type PlacementPolicy struct {
Replicas []*Replica `json:"replicas"`
ContainerBackupFactor uint32 `json:"containerBackupFactor"`
Selectors []*Selector `json:"selectors"`
Filters []*Filter `json:"filters"`
Unique bool `json:"unique"`
Replicas []Replica `json:"replicas"`
ContainerBackupFactor uint32 `json:"containerBackupFactor"`
Selectors []Selector `json:"selectors"`
Filters []Filter `json:"filters"`
Unique bool `json:"unique"`
}
var (
@ -914,14 +912,14 @@ func (x *PlacementPolicy) StableSize() (size int) {
return 0
}
for i := range x.Replicas {
size += proto.NestedStructureSize(1, x.Replicas[i])
size += proto.NestedStructureSizeUnchecked(1, &x.Replicas[i])
}
size += proto.UInt32Size(2, x.ContainerBackupFactor)
for i := range x.Selectors {
size += proto.NestedStructureSize(3, x.Selectors[i])
size += proto.NestedStructureSizeUnchecked(3, &x.Selectors[i])
}
for i := range x.Filters {
size += proto.NestedStructureSize(4, x.Filters[i])
size += proto.NestedStructureSizeUnchecked(4, &x.Filters[i])
}
size += proto.BoolSize(5, x.Unique)
return size
@ -941,22 +939,16 @@ func (x *PlacementPolicy) EmitProtobuf(mm *easyproto.MessageMarshaler) {
return
}
for i := range x.Replicas {
if x.Replicas[i] != nil {
x.Replicas[i].EmitProtobuf(mm.AppendMessage(1))
}
x.Replicas[i].EmitProtobuf(mm.AppendMessage(1))
}
if x.ContainerBackupFactor != 0 {
mm.AppendUint32(2, x.ContainerBackupFactor)
}
for i := range x.Selectors {
if x.Selectors[i] != nil {
x.Selectors[i].EmitProtobuf(mm.AppendMessage(3))
}
x.Selectors[i].EmitProtobuf(mm.AppendMessage(3))
}
for i := range x.Filters {
if x.Filters[i] != nil {
x.Filters[i].EmitProtobuf(mm.AppendMessage(4))
}
x.Filters[i].EmitProtobuf(mm.AppendMessage(4))
}
if x.Unique {
mm.AppendBool(5, x.Unique)
@ -977,8 +969,8 @@ func (x *PlacementPolicy) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Replicas")
}
x.Replicas = append(x.Replicas, new(Replica))
ff := x.Replicas[len(x.Replicas)-1]
x.Replicas = append(x.Replicas, Replica{})
ff := &x.Replicas[len(x.Replicas)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -993,8 +985,8 @@ func (x *PlacementPolicy) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Selectors")
}
x.Selectors = append(x.Selectors, new(Selector))
ff := x.Selectors[len(x.Selectors)-1]
x.Selectors = append(x.Selectors, Selector{})
ff := &x.Selectors[len(x.Selectors)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -1003,8 +995,8 @@ func (x *PlacementPolicy) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Filters")
}
x.Filters = append(x.Filters, new(Filter))
ff := x.Filters[len(x.Filters)-1]
x.Filters = append(x.Filters, Filter{})
ff := &x.Filters[len(x.Filters)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -1018,13 +1010,13 @@ func (x *PlacementPolicy) UnmarshalProtobuf(src []byte) (err error) {
}
return nil
}
func (x *PlacementPolicy) GetReplicas() []*Replica {
func (x *PlacementPolicy) GetReplicas() []Replica {
if x != nil {
return x.Replicas
}
return nil
}
func (x *PlacementPolicy) SetReplicas(v []*Replica) {
func (x *PlacementPolicy) SetReplicas(v []Replica) {
x.Replicas = v
}
func (x *PlacementPolicy) GetContainerBackupFactor() uint32 {
@ -1036,22 +1028,22 @@ func (x *PlacementPolicy) GetContainerBackupFactor() uint32 {
func (x *PlacementPolicy) SetContainerBackupFactor(v uint32) {
x.ContainerBackupFactor = v
}
func (x *PlacementPolicy) GetSelectors() []*Selector {
func (x *PlacementPolicy) GetSelectors() []Selector {
if x != nil {
return x.Selectors
}
return nil
}
func (x *PlacementPolicy) SetSelectors(v []*Selector) {
func (x *PlacementPolicy) SetSelectors(v []Selector) {
x.Selectors = v
}
func (x *PlacementPolicy) GetFilters() []*Filter {
func (x *PlacementPolicy) GetFilters() []Filter {
if x != nil {
return x.Filters
}
return nil
}
func (x *PlacementPolicy) SetFilters(v []*Filter) {
func (x *PlacementPolicy) SetFilters(v []Filter) {
x.Filters = v
}
func (x *PlacementPolicy) GetUnique() bool {
@ -1152,11 +1144,11 @@ func (x *PlacementPolicy) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch key {
case "replicas":
{
var f *Replica
var list []*Replica
var f Replica
var list []Replica
in.Delim('[')
for !in.IsDelim(']') {
f = new(Replica)
f = Replica{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -1172,11 +1164,11 @@ func (x *PlacementPolicy) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "selectors":
{
var f *Selector
var list []*Selector
var f Selector
var list []Selector
in.Delim('[')
for !in.IsDelim(']') {
f = new(Selector)
f = Selector{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -1186,11 +1178,11 @@ func (x *PlacementPolicy) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "filters":
{
var f *Filter
var list []*Filter
var f Filter
var list []Filter
in.Delim('[')
for !in.IsDelim(']') {
f = new(Filter)
f = Filter{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -1457,10 +1449,10 @@ func (x *NodeInfo_Attribute) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
type NodeInfo struct {
PublicKey []byte `json:"publicKey"`
Addresses []string `json:"addresses"`
Attributes []*NodeInfo_Attribute `json:"attributes"`
State NodeInfo_State `json:"state"`
PublicKey []byte `json:"publicKey"`
Addresses []string `json:"addresses"`
Attributes []NodeInfo_Attribute `json:"attributes"`
State NodeInfo_State `json:"state"`
}
var (
@ -1480,7 +1472,7 @@ func (x *NodeInfo) StableSize() (size int) {
size += proto.BytesSize(1, x.PublicKey)
size += proto.RepeatedStringSize(2, x.Addresses)
for i := range x.Attributes {
size += proto.NestedStructureSize(3, x.Attributes[i])
size += proto.NestedStructureSizeUnchecked(3, &x.Attributes[i])
}
size += proto.EnumSize(4, int32(x.State))
return size
@ -1506,9 +1498,7 @@ func (x *NodeInfo) EmitProtobuf(mm *easyproto.MessageMarshaler) {
mm.AppendString(2, x.Addresses[j])
}
for i := range x.Attributes {
if x.Attributes[i] != nil {
x.Attributes[i].EmitProtobuf(mm.AppendMessage(3))
}
x.Attributes[i].EmitProtobuf(mm.AppendMessage(3))
}
if int32(x.State) != 0 {
mm.AppendInt32(4, int32(x.State))
@ -1541,8 +1531,8 @@ func (x *NodeInfo) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Attributes")
}
x.Attributes = append(x.Attributes, new(NodeInfo_Attribute))
ff := x.Attributes[len(x.Attributes)-1]
x.Attributes = append(x.Attributes, NodeInfo_Attribute{})
ff := &x.Attributes[len(x.Attributes)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -1574,13 +1564,13 @@ func (x *NodeInfo) GetAddresses() []string {
func (x *NodeInfo) SetAddresses(v []string) {
x.Addresses = v
}
func (x *NodeInfo) GetAttributes() []*NodeInfo_Attribute {
func (x *NodeInfo) GetAttributes() []NodeInfo_Attribute {
if x != nil {
return x.Attributes
}
return nil
}
func (x *NodeInfo) SetAttributes(v []*NodeInfo_Attribute) {
func (x *NodeInfo) SetAttributes(v []NodeInfo_Attribute) {
x.Attributes = v
}
func (x *NodeInfo) GetState() NodeInfo_State {
@ -1688,11 +1678,11 @@ func (x *NodeInfo) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "attributes":
{
var f *NodeInfo_Attribute
var list []*NodeInfo_Attribute
var f NodeInfo_Attribute
var list []NodeInfo_Attribute
in.Delim('[')
for !in.IsDelim(']') {
f = new(NodeInfo_Attribute)
f = NodeInfo_Attribute{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -1732,8 +1722,8 @@ func (x *NodeInfo) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
type Netmap struct {
Epoch uint64 `json:"epoch"`
Nodes []*NodeInfo `json:"nodes"`
Epoch uint64 `json:"epoch"`
Nodes []NodeInfo `json:"nodes"`
}
var (
@ -1752,7 +1742,7 @@ func (x *Netmap) StableSize() (size int) {
}
size += proto.UInt64Size(1, x.Epoch)
for i := range x.Nodes {
size += proto.NestedStructureSize(2, x.Nodes[i])
size += proto.NestedStructureSizeUnchecked(2, &x.Nodes[i])
}
return size
}
@ -1774,9 +1764,7 @@ func (x *Netmap) EmitProtobuf(mm *easyproto.MessageMarshaler) {
mm.AppendUint64(1, x.Epoch)
}
for i := range x.Nodes {
if x.Nodes[i] != nil {
x.Nodes[i].EmitProtobuf(mm.AppendMessage(2))
}
x.Nodes[i].EmitProtobuf(mm.AppendMessage(2))
}
}
@ -1800,8 +1788,8 @@ func (x *Netmap) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Nodes")
}
x.Nodes = append(x.Nodes, new(NodeInfo))
ff := x.Nodes[len(x.Nodes)-1]
x.Nodes = append(x.Nodes, NodeInfo{})
ff := &x.Nodes[len(x.Nodes)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -1818,13 +1806,13 @@ func (x *Netmap) GetEpoch() uint64 {
func (x *Netmap) SetEpoch(v uint64) {
x.Epoch = v
}
func (x *Netmap) GetNodes() []*NodeInfo {
func (x *Netmap) GetNodes() []NodeInfo {
if x != nil {
return x.Nodes
}
return nil
}
func (x *Netmap) SetNodes(v []*NodeInfo) {
func (x *Netmap) SetNodes(v []NodeInfo) {
x.Nodes = v
}
@ -1893,11 +1881,11 @@ func (x *Netmap) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "nodes":
{
var f *NodeInfo
var list []*NodeInfo
var f NodeInfo
var list []NodeInfo
in.Delim('[')
for !in.IsDelim(']') {
f = new(NodeInfo)
f = NodeInfo{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -2075,7 +2063,7 @@ func (x *NetworkConfig_Parameter) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
type NetworkConfig struct {
Parameters []*NetworkConfig_Parameter `json:"parameters"`
Parameters []NetworkConfig_Parameter `json:"parameters"`
}
var (
@ -2093,7 +2081,7 @@ func (x *NetworkConfig) StableSize() (size int) {
return 0
}
for i := range x.Parameters {
size += proto.NestedStructureSize(1, x.Parameters[i])
size += proto.NestedStructureSizeUnchecked(1, &x.Parameters[i])
}
return size
}
@ -2112,9 +2100,7 @@ func (x *NetworkConfig) EmitProtobuf(mm *easyproto.MessageMarshaler) {
return
}
for i := range x.Parameters {
if x.Parameters[i] != nil {
x.Parameters[i].EmitProtobuf(mm.AppendMessage(1))
}
x.Parameters[i].EmitProtobuf(mm.AppendMessage(1))
}
}
@ -2132,8 +2118,8 @@ func (x *NetworkConfig) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Parameters")
}
x.Parameters = append(x.Parameters, new(NetworkConfig_Parameter))
ff := x.Parameters[len(x.Parameters)-1]
x.Parameters = append(x.Parameters, NetworkConfig_Parameter{})
ff := &x.Parameters[len(x.Parameters)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -2141,13 +2127,13 @@ func (x *NetworkConfig) UnmarshalProtobuf(src []byte) (err error) {
}
return nil
}
func (x *NetworkConfig) GetParameters() []*NetworkConfig_Parameter {
func (x *NetworkConfig) GetParameters() []NetworkConfig_Parameter {
if x != nil {
return x.Parameters
}
return nil
}
func (x *NetworkConfig) SetParameters(v []*NetworkConfig_Parameter) {
func (x *NetworkConfig) SetParameters(v []NetworkConfig_Parameter) {
x.Parameters = v
}
@ -2205,11 +2191,11 @@ func (x *NetworkConfig) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch key {
case "parameters":
{
var f *NetworkConfig_Parameter
var list []*NetworkConfig_Parameter
var f NetworkConfig_Parameter
var list []NetworkConfig_Parameter
in.Delim('[')
for !in.IsDelim(']') {
f = new(NetworkConfig_Parameter)
f = NetworkConfig_Parameter{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()

View file

@ -142,28 +142,26 @@ func (a *Attribute) FromGRPCMessage(m grpc.Message) error {
return nil
}
func AttributesToGRPC(xs []Attribute) (res []*object.Header_Attribute) {
func AttributesToGRPC(xs []Attribute) (res []object.Header_Attribute) {
if xs != nil {
res = make([]*object.Header_Attribute, 0, len(xs))
res = make([]object.Header_Attribute, 0, len(xs))
for i := range xs {
res = append(res, xs[i].ToGRPCMessage().(*object.Header_Attribute))
res = append(res, *xs[i].ToGRPCMessage().(*object.Header_Attribute))
}
}
return
}
func AttributesFromGRPC(xs []*object.Header_Attribute) (res []Attribute, err error) {
func AttributesFromGRPC(xs []object.Header_Attribute) (res []Attribute, err error) {
if xs != nil {
res = make([]Attribute, len(xs))
for i := range xs {
if xs[i] != nil {
err = res[i].FromGRPCMessage(xs[i])
if err != nil {
return
}
err = res[i].FromGRPCMessage(&xs[i])
if err != nil {
return
}
}
}
@ -683,9 +681,9 @@ func (s *ECInfo) ToGRPCMessage() grpc.Message {
m = new(object.ECInfo)
if s.Chunks != nil {
chunks := make([]*object.ECInfo_Chunk, len(s.Chunks))
chunks := make([]object.ECInfo_Chunk, len(s.Chunks))
for i := range chunks {
chunks[i] = s.Chunks[i].ToGRPCMessage().(*object.ECInfo_Chunk)
chunks[i] = *s.Chunks[i].ToGRPCMessage().(*object.ECInfo_Chunk)
}
m.Chunks = chunks
}
@ -706,7 +704,7 @@ func (s *ECInfo) FromGRPCMessage(m grpc.Message) error {
} else {
s.Chunks = make([]ECChunk, len(chunks))
for i := range chunks {
if err := s.Chunks[i].FromGRPCMessage(chunks[i]); err != nil {
if err := s.Chunks[i].FromGRPCMessage(&chunks[i]); err != nil {
return err
}
}
@ -1626,28 +1624,26 @@ func (f *SearchFilter) FromGRPCMessage(m grpc.Message) error {
return nil
}
func SearchFiltersToGRPC(fs []SearchFilter) (res []*object.SearchRequest_Body_Filter) {
func SearchFiltersToGRPC(fs []SearchFilter) (res []object.SearchRequest_Body_Filter) {
if fs != nil {
res = make([]*object.SearchRequest_Body_Filter, 0, len(fs))
res = make([]object.SearchRequest_Body_Filter, 0, len(fs))
for i := range fs {
res = append(res, fs[i].ToGRPCMessage().(*object.SearchRequest_Body_Filter))
res = append(res, *fs[i].ToGRPCMessage().(*object.SearchRequest_Body_Filter))
}
}
return
}
func SearchFiltersFromGRPC(fs []*object.SearchRequest_Body_Filter) (res []SearchFilter, err error) {
func SearchFiltersFromGRPC(fs []object.SearchRequest_Body_Filter) (res []SearchFilter, err error) {
if fs != nil {
res = make([]SearchFilter, len(fs))
for i := range fs {
if fs[i] != nil {
err = res[i].FromGRPCMessage(fs[i])
if err != nil {
return
}
err = res[i].FromGRPCMessage(&fs[i])
if err != nil {
return
}
}
}
@ -1827,28 +1823,26 @@ func (r *Range) FromGRPCMessage(m grpc.Message) error {
return nil
}
func RangesToGRPC(rs []Range) (res []*object.Range) {
func RangesToGRPC(rs []Range) (res []object.Range) {
if rs != nil {
res = make([]*object.Range, 0, len(rs))
res = make([]object.Range, 0, len(rs))
for i := range rs {
res = append(res, rs[i].ToGRPCMessage().(*object.Range))
res = append(res, *rs[i].ToGRPCMessage().(*object.Range))
}
}
return
}
func RangesFromGRPC(rs []*object.Range) (res []Range, err error) {
func RangesFromGRPC(rs []object.Range) (res []Range, err error) {
if rs != nil {
res = make([]Range, len(rs))
for i := range rs {
if rs[i] != nil {
err = res[i].FromGRPCMessage(rs[i])
if err != nil {
return
}
err = res[i].FromGRPCMessage(&rs[i])
if err != nil {
return
}
}
}

View file

@ -4201,9 +4201,9 @@ func (x *SearchRequest_Body_Filter) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
type SearchRequest_Body struct {
ContainerId *grpc.ContainerID `json:"containerId"`
Version uint32 `json:"version"`
Filters []*SearchRequest_Body_Filter `json:"filters"`
ContainerId *grpc.ContainerID `json:"containerId"`
Version uint32 `json:"version"`
Filters []SearchRequest_Body_Filter `json:"filters"`
}
var (
@ -4223,7 +4223,7 @@ func (x *SearchRequest_Body) StableSize() (size int) {
size += proto.NestedStructureSize(1, x.ContainerId)
size += proto.UInt32Size(2, x.Version)
for i := range x.Filters {
size += proto.NestedStructureSize(3, x.Filters[i])
size += proto.NestedStructureSizeUnchecked(3, &x.Filters[i])
}
return size
}
@ -4248,9 +4248,7 @@ func (x *SearchRequest_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) {
mm.AppendUint32(2, x.Version)
}
for i := range x.Filters {
if x.Filters[i] != nil {
x.Filters[i].EmitProtobuf(mm.AppendMessage(3))
}
x.Filters[i].EmitProtobuf(mm.AppendMessage(3))
}
}
@ -4283,8 +4281,8 @@ func (x *SearchRequest_Body) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Filters")
}
x.Filters = append(x.Filters, new(SearchRequest_Body_Filter))
ff := x.Filters[len(x.Filters)-1]
x.Filters = append(x.Filters, SearchRequest_Body_Filter{})
ff := &x.Filters[len(x.Filters)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -4310,13 +4308,13 @@ func (x *SearchRequest_Body) GetVersion() uint32 {
func (x *SearchRequest_Body) SetVersion(v uint32) {
x.Version = v
}
func (x *SearchRequest_Body) GetFilters() []*SearchRequest_Body_Filter {
func (x *SearchRequest_Body) GetFilters() []SearchRequest_Body_Filter {
if x != nil {
return x.Filters
}
return nil
}
func (x *SearchRequest_Body) SetFilters(v []*SearchRequest_Body_Filter) {
func (x *SearchRequest_Body) SetFilters(v []SearchRequest_Body_Filter) {
x.Filters = v
}
@ -4397,11 +4395,11 @@ func (x *SearchRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "filters":
{
var f *SearchRequest_Body_Filter
var list []*SearchRequest_Body_Filter
var f SearchRequest_Body_Filter
var list []SearchRequest_Body_Filter
in.Delim('[')
for !in.IsDelim(']') {
f = new(SearchRequest_Body_Filter)
f = SearchRequest_Body_Filter{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -4640,7 +4638,7 @@ func (x *SearchRequest) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
type SearchResponse_Body struct {
IdList []*grpc.ObjectID `json:"idList"`
IdList []grpc.ObjectID `json:"idList"`
}
var (
@ -4658,7 +4656,7 @@ func (x *SearchResponse_Body) StableSize() (size int) {
return 0
}
for i := range x.IdList {
size += proto.NestedStructureSize(1, x.IdList[i])
size += proto.NestedStructureSizeUnchecked(1, &x.IdList[i])
}
return size
}
@ -4677,9 +4675,7 @@ func (x *SearchResponse_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) {
return
}
for i := range x.IdList {
if x.IdList[i] != nil {
x.IdList[i].EmitProtobuf(mm.AppendMessage(1))
}
x.IdList[i].EmitProtobuf(mm.AppendMessage(1))
}
}
@ -4697,8 +4693,8 @@ func (x *SearchResponse_Body) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "IdList")
}
x.IdList = append(x.IdList, new(grpc.ObjectID))
ff := x.IdList[len(x.IdList)-1]
x.IdList = append(x.IdList, grpc.ObjectID{})
ff := &x.IdList[len(x.IdList)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -4706,13 +4702,13 @@ func (x *SearchResponse_Body) UnmarshalProtobuf(src []byte) (err error) {
}
return nil
}
func (x *SearchResponse_Body) GetIdList() []*grpc.ObjectID {
func (x *SearchResponse_Body) GetIdList() []grpc.ObjectID {
if x != nil {
return x.IdList
}
return nil
}
func (x *SearchResponse_Body) SetIdList(v []*grpc.ObjectID) {
func (x *SearchResponse_Body) SetIdList(v []grpc.ObjectID) {
x.IdList = v
}
@ -4770,11 +4766,11 @@ func (x *SearchResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch key {
case "idList":
{
var f *grpc.ObjectID
var list []*grpc.ObjectID
var f grpc.ObjectID
var list []grpc.ObjectID
in.Delim('[')
for !in.IsDelim(']') {
f = new(grpc.ObjectID)
f = grpc.ObjectID{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -6077,7 +6073,7 @@ func (x *GetRangeResponse) UnmarshalEasyJSON(in *jlexer.Lexer) {
type GetRangeHashRequest_Body struct {
Address *grpc.Address `json:"address"`
Ranges []*Range `json:"ranges"`
Ranges []Range `json:"ranges"`
Salt []byte `json:"salt"`
Type grpc.ChecksumType `json:"type"`
}
@ -6098,7 +6094,7 @@ func (x *GetRangeHashRequest_Body) StableSize() (size int) {
}
size += proto.NestedStructureSize(1, x.Address)
for i := range x.Ranges {
size += proto.NestedStructureSize(2, x.Ranges[i])
size += proto.NestedStructureSizeUnchecked(2, &x.Ranges[i])
}
size += proto.BytesSize(3, x.Salt)
size += proto.EnumSize(4, int32(x.Type))
@ -6122,9 +6118,7 @@ func (x *GetRangeHashRequest_Body) EmitProtobuf(mm *easyproto.MessageMarshaler)
x.Address.EmitProtobuf(mm.AppendMessage(1))
}
for i := range x.Ranges {
if x.Ranges[i] != nil {
x.Ranges[i].EmitProtobuf(mm.AppendMessage(2))
}
x.Ranges[i].EmitProtobuf(mm.AppendMessage(2))
}
if len(x.Salt) != 0 {
mm.AppendBytes(3, x.Salt)
@ -6157,8 +6151,8 @@ func (x *GetRangeHashRequest_Body) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Ranges")
}
x.Ranges = append(x.Ranges, new(Range))
ff := x.Ranges[len(x.Ranges)-1]
x.Ranges = append(x.Ranges, Range{})
ff := &x.Ranges[len(x.Ranges)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -6187,13 +6181,13 @@ func (x *GetRangeHashRequest_Body) GetAddress() *grpc.Address {
func (x *GetRangeHashRequest_Body) SetAddress(v *grpc.Address) {
x.Address = v
}
func (x *GetRangeHashRequest_Body) GetRanges() []*Range {
func (x *GetRangeHashRequest_Body) GetRanges() []Range {
if x != nil {
return x.Ranges
}
return nil
}
func (x *GetRangeHashRequest_Body) SetRanges(v []*Range) {
func (x *GetRangeHashRequest_Body) SetRanges(v []Range) {
x.Ranges = v
}
func (x *GetRangeHashRequest_Body) GetSalt() []byte {
@ -6291,11 +6285,11 @@ func (x *GetRangeHashRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "ranges":
{
var f *Range
var list []*Range
var f Range
var list []Range
in.Delim('[')
for !in.IsDelim(']') {
f = new(Range)
f = Range{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -7855,7 +7849,7 @@ func (x *PatchRequest_Body_Patch) UnmarshalEasyJSON(in *jlexer.Lexer) {
type PatchRequest_Body struct {
Address *grpc.Address `json:"address"`
NewAttributes []*Header_Attribute `json:"newAttributes"`
NewAttributes []Header_Attribute `json:"newAttributes"`
ReplaceAttributes bool `json:"replaceAttributes"`
Patch *PatchRequest_Body_Patch `json:"patch"`
}
@ -7876,7 +7870,7 @@ func (x *PatchRequest_Body) StableSize() (size int) {
}
size += proto.NestedStructureSize(1, x.Address)
for i := range x.NewAttributes {
size += proto.NestedStructureSize(2, x.NewAttributes[i])
size += proto.NestedStructureSizeUnchecked(2, &x.NewAttributes[i])
}
size += proto.BoolSize(3, x.ReplaceAttributes)
size += proto.NestedStructureSize(4, x.Patch)
@ -7900,9 +7894,7 @@ func (x *PatchRequest_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) {
x.Address.EmitProtobuf(mm.AppendMessage(1))
}
for i := range x.NewAttributes {
if x.NewAttributes[i] != nil {
x.NewAttributes[i].EmitProtobuf(mm.AppendMessage(2))
}
x.NewAttributes[i].EmitProtobuf(mm.AppendMessage(2))
}
if x.ReplaceAttributes {
mm.AppendBool(3, x.ReplaceAttributes)
@ -7935,8 +7927,8 @@ func (x *PatchRequest_Body) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "NewAttributes")
}
x.NewAttributes = append(x.NewAttributes, new(Header_Attribute))
ff := x.NewAttributes[len(x.NewAttributes)-1]
x.NewAttributes = append(x.NewAttributes, Header_Attribute{})
ff := &x.NewAttributes[len(x.NewAttributes)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -7968,13 +7960,13 @@ func (x *PatchRequest_Body) GetAddress() *grpc.Address {
func (x *PatchRequest_Body) SetAddress(v *grpc.Address) {
x.Address = v
}
func (x *PatchRequest_Body) GetNewAttributes() []*Header_Attribute {
func (x *PatchRequest_Body) GetNewAttributes() []Header_Attribute {
if x != nil {
return x.NewAttributes
}
return nil
}
func (x *PatchRequest_Body) SetNewAttributes(v []*Header_Attribute) {
func (x *PatchRequest_Body) SetNewAttributes(v []Header_Attribute) {
x.NewAttributes = v
}
func (x *PatchRequest_Body) GetReplaceAttributes() bool {
@ -8072,11 +8064,11 @@ func (x *PatchRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "newAttributes":
{
var f *Header_Attribute
var list []*Header_Attribute
var f Header_Attribute
var list []Header_Attribute
in.Delim('[')
for !in.IsDelim(']') {
f = new(Header_Attribute)
f = Header_Attribute{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()

View file

@ -600,12 +600,12 @@ func (x *Header_Attribute) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
type Header_Split struct {
Parent *grpc.ObjectID `json:"parent"`
Previous *grpc.ObjectID `json:"previous"`
ParentSignature *grpc.Signature `json:"parentSignature"`
ParentHeader *Header `json:"parentHeader"`
Children []*grpc.ObjectID `json:"children"`
SplitId []byte `json:"splitID"`
Parent *grpc.ObjectID `json:"parent"`
Previous *grpc.ObjectID `json:"previous"`
ParentSignature *grpc.Signature `json:"parentSignature"`
ParentHeader *Header `json:"parentHeader"`
Children []grpc.ObjectID `json:"children"`
SplitId []byte `json:"splitID"`
}
var (
@ -627,7 +627,7 @@ func (x *Header_Split) StableSize() (size int) {
size += proto.NestedStructureSize(3, x.ParentSignature)
size += proto.NestedStructureSize(4, x.ParentHeader)
for i := range x.Children {
size += proto.NestedStructureSize(5, x.Children[i])
size += proto.NestedStructureSizeUnchecked(5, &x.Children[i])
}
size += proto.BytesSize(6, x.SplitId)
return size
@ -659,9 +659,7 @@ func (x *Header_Split) EmitProtobuf(mm *easyproto.MessageMarshaler) {
x.ParentHeader.EmitProtobuf(mm.AppendMessage(4))
}
for i := range x.Children {
if x.Children[i] != nil {
x.Children[i].EmitProtobuf(mm.AppendMessage(5))
}
x.Children[i].EmitProtobuf(mm.AppendMessage(5))
}
if len(x.SplitId) != 0 {
mm.AppendBytes(6, x.SplitId)
@ -718,8 +716,8 @@ func (x *Header_Split) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Children")
}
x.Children = append(x.Children, new(grpc.ObjectID))
ff := x.Children[len(x.Children)-1]
x.Children = append(x.Children, grpc.ObjectID{})
ff := &x.Children[len(x.Children)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -769,13 +767,13 @@ func (x *Header_Split) GetParentHeader() *Header {
func (x *Header_Split) SetParentHeader(v *Header) {
x.ParentHeader = v
}
func (x *Header_Split) GetChildren() []*grpc.ObjectID {
func (x *Header_Split) GetChildren() []grpc.ObjectID {
if x != nil {
return x.Children
}
return nil
}
func (x *Header_Split) SetChildren(v []*grpc.ObjectID) {
func (x *Header_Split) SetChildren(v []grpc.ObjectID) {
x.Children = v
}
func (x *Header_Split) GetSplitId() []byte {
@ -895,11 +893,11 @@ func (x *Header_Split) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "children":
{
var f *grpc.ObjectID
var list []*grpc.ObjectID
var f grpc.ObjectID
var list []grpc.ObjectID
in.Delim('[')
for !in.IsDelim(']') {
f = new(grpc.ObjectID)
f = grpc.ObjectID{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -923,14 +921,14 @@ func (x *Header_Split) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
type Header_EC struct {
Parent *grpc.ObjectID `json:"parent"`
Index uint32 `json:"index"`
Total uint32 `json:"total"`
HeaderLength uint32 `json:"headerLength"`
Header []byte `json:"header"`
ParentSplitId []byte `json:"parentSplitID"`
ParentSplitParentId *grpc.ObjectID `json:"parentSplitParentID"`
ParentAttributes []*Header_Attribute `json:"parentAttributes"`
Parent *grpc.ObjectID `json:"parent"`
Index uint32 `json:"index"`
Total uint32 `json:"total"`
HeaderLength uint32 `json:"headerLength"`
Header []byte `json:"header"`
ParentSplitId []byte `json:"parentSplitID"`
ParentSplitParentId *grpc.ObjectID `json:"parentSplitParentID"`
ParentAttributes []Header_Attribute `json:"parentAttributes"`
}
var (
@ -955,7 +953,7 @@ func (x *Header_EC) StableSize() (size int) {
size += proto.BytesSize(6, x.ParentSplitId)
size += proto.NestedStructureSize(7, x.ParentSplitParentId)
for i := range x.ParentAttributes {
size += proto.NestedStructureSize(8, x.ParentAttributes[i])
size += proto.NestedStructureSizeUnchecked(8, &x.ParentAttributes[i])
}
return size
}
@ -995,9 +993,7 @@ func (x *Header_EC) EmitProtobuf(mm *easyproto.MessageMarshaler) {
x.ParentSplitParentId.EmitProtobuf(mm.AppendMessage(7))
}
for i := range x.ParentAttributes {
if x.ParentAttributes[i] != nil {
x.ParentAttributes[i].EmitProtobuf(mm.AppendMessage(8))
}
x.ParentAttributes[i].EmitProtobuf(mm.AppendMessage(8))
}
}
@ -1063,8 +1059,8 @@ func (x *Header_EC) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "ParentAttributes")
}
x.ParentAttributes = append(x.ParentAttributes, new(Header_Attribute))
ff := x.ParentAttributes[len(x.ParentAttributes)-1]
x.ParentAttributes = append(x.ParentAttributes, Header_Attribute{})
ff := &x.ParentAttributes[len(x.ParentAttributes)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -1135,13 +1131,13 @@ func (x *Header_EC) GetParentSplitParentId() *grpc.ObjectID {
func (x *Header_EC) SetParentSplitParentId(v *grpc.ObjectID) {
x.ParentSplitParentId = v
}
func (x *Header_EC) GetParentAttributes() []*Header_Attribute {
func (x *Header_EC) GetParentAttributes() []Header_Attribute {
if x != nil {
return x.ParentAttributes
}
return nil
}
func (x *Header_EC) SetParentAttributes(v []*Header_Attribute) {
func (x *Header_EC) SetParentAttributes(v []Header_Attribute) {
x.ParentAttributes = v
}
@ -1278,11 +1274,11 @@ func (x *Header_EC) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "parentAttributes":
{
var f *Header_Attribute
var list []*Header_Attribute
var f Header_Attribute
var list []Header_Attribute
in.Delim('[')
for !in.IsDelim(']') {
f = new(Header_Attribute)
f = Header_Attribute{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -1309,7 +1305,7 @@ type Header struct {
ObjectType ObjectType `json:"objectType"`
HomomorphicHash *grpc.Checksum `json:"homomorphicHash"`
SessionToken *grpc1.SessionToken `json:"sessionToken"`
Attributes []*Header_Attribute `json:"attributes"`
Attributes []Header_Attribute `json:"attributes"`
Split *Header_Split `json:"split"`
Ec *Header_EC `json:"ec"`
}
@ -1338,7 +1334,7 @@ func (x *Header) StableSize() (size int) {
size += proto.NestedStructureSize(8, x.HomomorphicHash)
size += proto.NestedStructureSize(9, x.SessionToken)
for i := range x.Attributes {
size += proto.NestedStructureSize(10, x.Attributes[i])
size += proto.NestedStructureSizeUnchecked(10, &x.Attributes[i])
}
size += proto.NestedStructureSize(11, x.Split)
size += proto.NestedStructureSize(12, x.Ec)
@ -1386,9 +1382,7 @@ func (x *Header) EmitProtobuf(mm *easyproto.MessageMarshaler) {
x.SessionToken.EmitProtobuf(mm.AppendMessage(9))
}
for i := range x.Attributes {
if x.Attributes[i] != nil {
x.Attributes[i].EmitProtobuf(mm.AppendMessage(10))
}
x.Attributes[i].EmitProtobuf(mm.AppendMessage(10))
}
if x.Split != nil {
x.Split.EmitProtobuf(mm.AppendMessage(11))
@ -1484,8 +1478,8 @@ func (x *Header) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Attributes")
}
x.Attributes = append(x.Attributes, new(Header_Attribute))
ff := x.Attributes[len(x.Attributes)-1]
x.Attributes = append(x.Attributes, Header_Attribute{})
ff := &x.Attributes[len(x.Attributes)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -1592,13 +1586,13 @@ func (x *Header) GetSessionToken() *grpc1.SessionToken {
func (x *Header) SetSessionToken(v *grpc1.SessionToken) {
x.SessionToken = v
}
func (x *Header) GetAttributes() []*Header_Attribute {
func (x *Header) GetAttributes() []Header_Attribute {
if x != nil {
return x.Attributes
}
return nil
}
func (x *Header) SetAttributes(v []*Header_Attribute) {
func (x *Header) SetAttributes(v []Header_Attribute) {
x.Attributes = v
}
func (x *Header) GetSplit() *Header_Split {
@ -1805,11 +1799,11 @@ func (x *Header) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "attributes":
{
var f *Header_Attribute
var list []*Header_Attribute
var f Header_Attribute
var list []Header_Attribute
in.Delim('[')
for !in.IsDelim(']') {
f = new(Header_Attribute)
f = Header_Attribute{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -2469,7 +2463,7 @@ func (x *ECInfo_Chunk) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
type ECInfo struct {
Chunks []*ECInfo_Chunk `json:"chunks"`
Chunks []ECInfo_Chunk `json:"chunks"`
}
var (
@ -2487,7 +2481,7 @@ func (x *ECInfo) StableSize() (size int) {
return 0
}
for i := range x.Chunks {
size += proto.NestedStructureSize(1, x.Chunks[i])
size += proto.NestedStructureSizeUnchecked(1, &x.Chunks[i])
}
return size
}
@ -2506,9 +2500,7 @@ func (x *ECInfo) EmitProtobuf(mm *easyproto.MessageMarshaler) {
return
}
for i := range x.Chunks {
if x.Chunks[i] != nil {
x.Chunks[i].EmitProtobuf(mm.AppendMessage(1))
}
x.Chunks[i].EmitProtobuf(mm.AppendMessage(1))
}
}
@ -2526,8 +2518,8 @@ func (x *ECInfo) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Chunks")
}
x.Chunks = append(x.Chunks, new(ECInfo_Chunk))
ff := x.Chunks[len(x.Chunks)-1]
x.Chunks = append(x.Chunks, ECInfo_Chunk{})
ff := &x.Chunks[len(x.Chunks)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -2535,13 +2527,13 @@ func (x *ECInfo) UnmarshalProtobuf(src []byte) (err error) {
}
return nil
}
func (x *ECInfo) GetChunks() []*ECInfo_Chunk {
func (x *ECInfo) GetChunks() []ECInfo_Chunk {
if x != nil {
return x.Chunks
}
return nil
}
func (x *ECInfo) SetChunks(v []*ECInfo_Chunk) {
func (x *ECInfo) SetChunks(v []ECInfo_Chunk) {
x.Chunks = v
}
@ -2599,11 +2591,11 @@ func (x *ECInfo) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch key {
case "chunks":
{
var f *ECInfo_Chunk
var list []*ECInfo_Chunk
var f ECInfo_Chunk
var list []ECInfo_Chunk
in.Delim('[')
for !in.IsDelim(']') {
f = new(ECInfo_Chunk)
f = ECInfo_Chunk{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()

View file

@ -89,13 +89,13 @@ func (x *Lock) ToGRPCMessage() grpc.Message {
if x != nil {
m = new(lock.Lock)
var members []*refsGRPC.ObjectID
var members []refsGRPC.ObjectID
if x.members != nil {
members = make([]*refsGRPC.ObjectID, len(x.members))
members = make([]refsGRPC.ObjectID, len(x.members))
for i := range x.members {
members[i] = x.members[i].ToGRPCMessage().(*refsGRPC.ObjectID)
members[i] = *x.members[i].ToGRPCMessage().(*refsGRPC.ObjectID)
}
}
@ -119,7 +119,7 @@ func (x *Lock) FromGRPCMessage(m grpc.Message) error {
var err error
for i := range x.members {
err = x.members[i].FromGRPCMessage(members[i])
err = x.members[i].FromGRPCMessage(&members[i])
if err != nil {
return err
}

View file

@ -52,28 +52,26 @@ func (c *ContainerID) FromGRPCMessage(m grpc.Message) error {
return nil
}
func ContainerIDsToGRPCMessage(ids []ContainerID) (res []*refs.ContainerID) {
func ContainerIDsToGRPCMessage(ids []ContainerID) (res []refs.ContainerID) {
if ids != nil {
res = make([]*refs.ContainerID, 0, len(ids))
res = make([]refs.ContainerID, 0, len(ids))
for i := range ids {
res = append(res, ids[i].ToGRPCMessage().(*refs.ContainerID))
res = append(res, *ids[i].ToGRPCMessage().(*refs.ContainerID))
}
}
return
}
func ContainerIDsFromGRPCMessage(idsV2 []*refs.ContainerID) (res []ContainerID, err error) {
func ContainerIDsFromGRPCMessage(idsV2 []refs.ContainerID) (res []ContainerID, err error) {
if idsV2 != nil {
res = make([]ContainerID, len(idsV2))
for i := range idsV2 {
if idsV2[i] != nil {
err = res[i].FromGRPCMessage(idsV2[i])
if err != nil {
return
}
err = res[i].FromGRPCMessage(&idsV2[i])
if err != nil {
return
}
}
}
@ -104,28 +102,26 @@ func (o *ObjectID) FromGRPCMessage(m grpc.Message) error {
return nil
}
func ObjectIDListToGRPCMessage(ids []ObjectID) (res []*refs.ObjectID) {
func ObjectIDListToGRPCMessage(ids []ObjectID) (res []refs.ObjectID) {
if ids != nil {
res = make([]*refs.ObjectID, 0, len(ids))
res = make([]refs.ObjectID, 0, len(ids))
for i := range ids {
res = append(res, ids[i].ToGRPCMessage().(*refs.ObjectID))
res = append(res, *ids[i].ToGRPCMessage().(*refs.ObjectID))
}
}
return
}
func ObjectIDListFromGRPCMessage(idsV2 []*refs.ObjectID) (res []ObjectID, err error) {
func ObjectIDListFromGRPCMessage(idsV2 []refs.ObjectID) (res []ObjectID, err error) {
if idsV2 != nil {
res = make([]ObjectID, len(idsV2))
for i := range idsV2 {
if idsV2[i] != nil {
err = res[i].FromGRPCMessage(idsV2[i])
if err != nil {
return
}
err = res[i].FromGRPCMessage(&idsV2[i])
if err != nil {
return
}
}
}

View file

@ -207,28 +207,26 @@ func (x *XHeader) FromGRPCMessage(m grpc.Message) error {
return nil
}
func XHeadersToGRPC(xs []XHeader) (res []*session.XHeader) {
func XHeadersToGRPC(xs []XHeader) (res []session.XHeader) {
if xs != nil {
res = make([]*session.XHeader, 0, len(xs))
res = make([]session.XHeader, 0, len(xs))
for i := range xs {
res = append(res, xs[i].ToGRPCMessage().(*session.XHeader))
res = append(res, *xs[i].ToGRPCMessage().(*session.XHeader))
}
}
return
}
func XHeadersFromGRPC(xs []*session.XHeader) (res []XHeader, err error) {
func XHeadersFromGRPC(xs []session.XHeader) (res []XHeader, err error) {
if xs != nil {
res = make([]XHeader, len(xs))
for i := range xs {
if xs[i] != nil {
err = res[i].FromGRPCMessage(xs[i])
if err != nil {
return
}
err = res[i].FromGRPCMessage(&xs[i])
if err != nil {
return
}
}
}

View file

@ -72,7 +72,7 @@ func (x *ObjectSessionContext_Verb) FromString(s string) bool {
type ObjectSessionContext_Target struct {
Container *grpc.ContainerID `json:"container"`
Objects []*grpc.ObjectID `json:"objects"`
Objects []grpc.ObjectID `json:"objects"`
}
var (
@ -91,7 +91,7 @@ func (x *ObjectSessionContext_Target) StableSize() (size int) {
}
size += proto.NestedStructureSize(1, x.Container)
for i := range x.Objects {
size += proto.NestedStructureSize(2, x.Objects[i])
size += proto.NestedStructureSizeUnchecked(2, &x.Objects[i])
}
return size
}
@ -113,9 +113,7 @@ func (x *ObjectSessionContext_Target) EmitProtobuf(mm *easyproto.MessageMarshale
x.Container.EmitProtobuf(mm.AppendMessage(1))
}
for i := range x.Objects {
if x.Objects[i] != nil {
x.Objects[i].EmitProtobuf(mm.AppendMessage(2))
}
x.Objects[i].EmitProtobuf(mm.AppendMessage(2))
}
}
@ -142,8 +140,8 @@ func (x *ObjectSessionContext_Target) UnmarshalProtobuf(src []byte) (err error)
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Objects")
}
x.Objects = append(x.Objects, new(grpc.ObjectID))
ff := x.Objects[len(x.Objects)-1]
x.Objects = append(x.Objects, grpc.ObjectID{})
ff := &x.Objects[len(x.Objects)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -160,13 +158,13 @@ func (x *ObjectSessionContext_Target) GetContainer() *grpc.ContainerID {
func (x *ObjectSessionContext_Target) SetContainer(v *grpc.ContainerID) {
x.Container = v
}
func (x *ObjectSessionContext_Target) GetObjects() []*grpc.ObjectID {
func (x *ObjectSessionContext_Target) GetObjects() []grpc.ObjectID {
if x != nil {
return x.Objects
}
return nil
}
func (x *ObjectSessionContext_Target) SetObjects(v []*grpc.ObjectID) {
func (x *ObjectSessionContext_Target) SetObjects(v []grpc.ObjectID) {
x.Objects = v
}
@ -236,11 +234,11 @@ func (x *ObjectSessionContext_Target) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "objects":
{
var f *grpc.ObjectID
var list []*grpc.ObjectID
var f grpc.ObjectID
var list []grpc.ObjectID
in.Delim('[')
for !in.IsDelim(']') {
f = new(grpc.ObjectID)
f = grpc.ObjectID{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -1551,7 +1549,7 @@ type RequestMetaHeader struct {
Version *grpc.Version `json:"version"`
Epoch uint64 `json:"epoch"`
Ttl uint32 `json:"ttl"`
XHeaders []*XHeader `json:"xHeaders"`
XHeaders []XHeader `json:"xHeaders"`
SessionToken *SessionToken `json:"sessionToken"`
BearerToken *grpc1.BearerToken `json:"bearerToken"`
Origin *RequestMetaHeader `json:"origin"`
@ -1576,7 +1574,7 @@ func (x *RequestMetaHeader) StableSize() (size int) {
size += proto.UInt64Size(2, x.Epoch)
size += proto.UInt32Size(3, x.Ttl)
for i := range x.XHeaders {
size += proto.NestedStructureSize(4, x.XHeaders[i])
size += proto.NestedStructureSizeUnchecked(4, &x.XHeaders[i])
}
size += proto.NestedStructureSize(5, x.SessionToken)
size += proto.NestedStructureSize(6, x.BearerToken)
@ -1608,9 +1606,7 @@ func (x *RequestMetaHeader) EmitProtobuf(mm *easyproto.MessageMarshaler) {
mm.AppendUint32(3, x.Ttl)
}
for i := range x.XHeaders {
if x.XHeaders[i] != nil {
x.XHeaders[i].EmitProtobuf(mm.AppendMessage(4))
}
x.XHeaders[i].EmitProtobuf(mm.AppendMessage(4))
}
if x.SessionToken != nil {
x.SessionToken.EmitProtobuf(mm.AppendMessage(5))
@ -1661,8 +1657,8 @@ func (x *RequestMetaHeader) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "XHeaders")
}
x.XHeaders = append(x.XHeaders, new(XHeader))
ff := x.XHeaders[len(x.XHeaders)-1]
x.XHeaders = append(x.XHeaders, XHeader{})
ff := &x.XHeaders[len(x.XHeaders)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -1730,13 +1726,13 @@ func (x *RequestMetaHeader) GetTtl() uint32 {
func (x *RequestMetaHeader) SetTtl(v uint32) {
x.Ttl = v
}
func (x *RequestMetaHeader) GetXHeaders() []*XHeader {
func (x *RequestMetaHeader) GetXHeaders() []XHeader {
if x != nil {
return x.XHeaders
}
return nil
}
func (x *RequestMetaHeader) SetXHeaders(v []*XHeader) {
func (x *RequestMetaHeader) SetXHeaders(v []XHeader) {
x.XHeaders = v
}
func (x *RequestMetaHeader) GetSessionToken() *SessionToken {
@ -1884,11 +1880,11 @@ func (x *RequestMetaHeader) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "xHeaders":
{
var f *XHeader
var list []*XHeader
var f XHeader
var list []XHeader
in.Delim('[')
for !in.IsDelim(']') {
f = new(XHeader)
f = XHeader{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
@ -1936,7 +1932,7 @@ type ResponseMetaHeader struct {
Version *grpc.Version `json:"version"`
Epoch uint64 `json:"epoch"`
Ttl uint32 `json:"ttl"`
XHeaders []*XHeader `json:"xHeaders"`
XHeaders []XHeader `json:"xHeaders"`
Origin *ResponseMetaHeader `json:"origin"`
Status *grpc2.Status `json:"status"`
}
@ -1959,7 +1955,7 @@ func (x *ResponseMetaHeader) StableSize() (size int) {
size += proto.UInt64Size(2, x.Epoch)
size += proto.UInt32Size(3, x.Ttl)
for i := range x.XHeaders {
size += proto.NestedStructureSize(4, x.XHeaders[i])
size += proto.NestedStructureSizeUnchecked(4, &x.XHeaders[i])
}
size += proto.NestedStructureSize(5, x.Origin)
size += proto.NestedStructureSize(6, x.Status)
@ -1989,9 +1985,7 @@ func (x *ResponseMetaHeader) EmitProtobuf(mm *easyproto.MessageMarshaler) {
mm.AppendUint32(3, x.Ttl)
}
for i := range x.XHeaders {
if x.XHeaders[i] != nil {
x.XHeaders[i].EmitProtobuf(mm.AppendMessage(4))
}
x.XHeaders[i].EmitProtobuf(mm.AppendMessage(4))
}
if x.Origin != nil {
x.Origin.EmitProtobuf(mm.AppendMessage(5))
@ -2036,8 +2030,8 @@ func (x *ResponseMetaHeader) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "XHeaders")
}
x.XHeaders = append(x.XHeaders, new(XHeader))
ff := x.XHeaders[len(x.XHeaders)-1]
x.XHeaders = append(x.XHeaders, XHeader{})
ff := &x.XHeaders[len(x.XHeaders)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -2090,13 +2084,13 @@ func (x *ResponseMetaHeader) GetTtl() uint32 {
func (x *ResponseMetaHeader) SetTtl(v uint32) {
x.Ttl = v
}
func (x *ResponseMetaHeader) GetXHeaders() []*XHeader {
func (x *ResponseMetaHeader) GetXHeaders() []XHeader {
if x != nil {
return x.XHeaders
}
return nil
}
func (x *ResponseMetaHeader) SetXHeaders(v []*XHeader) {
func (x *ResponseMetaHeader) SetXHeaders(v []XHeader) {
x.XHeaders = v
}
func (x *ResponseMetaHeader) GetOrigin() *ResponseMetaHeader {
@ -2216,11 +2210,11 @@ func (x *ResponseMetaHeader) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "xHeaders":
{
var f *XHeader
var list []*XHeader
var f XHeader
var list []XHeader
in.Delim('[')
for !in.IsDelim(']') {
f = new(XHeader)
f = XHeader{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()

View file

@ -48,13 +48,13 @@ func (x *Status) ToGRPCMessage() grpc.Message {
m.SetCode(CodeToGRPC(x.code))
m.SetMessage(x.msg)
var ds []*status.Status_Detail
var ds []status.Status_Detail
if ln := len(x.details); ln > 0 {
ds = make([]*status.Status_Detail, 0, ln)
ds = make([]status.Status_Detail, 0, ln)
for i := 0; i < ln; i++ {
ds = append(ds, x.details[i].ToGRPCMessage().(*status.Status_Detail))
ds = append(ds, *x.details[i].ToGRPCMessage().(*status.Status_Detail))
}
}
@ -81,10 +81,8 @@ func (x *Status) FromGRPCMessage(m grpc.Message) error {
ds = make([]Detail, ln)
for i := 0; i < ln; i++ {
if dsV2[i] != nil {
if err := ds[i].FromGRPCMessage(dsV2[i]); err != nil {
return err
}
if err := ds[i].FromGRPCMessage(&dsV2[i]); err != nil {
return err
}
}
}

View file

@ -429,9 +429,9 @@ func (x *Status_Detail) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
type Status struct {
Code uint32 `json:"code"`
Message string `json:"message"`
Details []*Status_Detail `json:"details"`
Code uint32 `json:"code"`
Message string `json:"message"`
Details []Status_Detail `json:"details"`
}
var (
@ -451,7 +451,7 @@ func (x *Status) StableSize() (size int) {
size += proto.UInt32Size(1, x.Code)
size += proto.StringSize(2, x.Message)
for i := range x.Details {
size += proto.NestedStructureSize(3, x.Details[i])
size += proto.NestedStructureSizeUnchecked(3, &x.Details[i])
}
return size
}
@ -476,9 +476,7 @@ func (x *Status) EmitProtobuf(mm *easyproto.MessageMarshaler) {
mm.AppendString(2, x.Message)
}
for i := range x.Details {
if x.Details[i] != nil {
x.Details[i].EmitProtobuf(mm.AppendMessage(3))
}
x.Details[i].EmitProtobuf(mm.AppendMessage(3))
}
}
@ -508,8 +506,8 @@ func (x *Status) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Details")
}
x.Details = append(x.Details, new(Status_Detail))
ff := x.Details[len(x.Details)-1]
x.Details = append(x.Details, Status_Detail{})
ff := &x.Details[len(x.Details)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -535,13 +533,13 @@ func (x *Status) GetMessage() string {
func (x *Status) SetMessage(v string) {
x.Message = v
}
func (x *Status) GetDetails() []*Status_Detail {
func (x *Status) GetDetails() []Status_Detail {
if x != nil {
return x.Details
}
return nil
}
func (x *Status) SetDetails(v []*Status_Detail) {
func (x *Status) SetDetails(v []Status_Detail) {
x.Details = v
}
@ -621,11 +619,11 @@ func (x *Status) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "details":
{
var f *Status_Detail
var list []*Status_Detail
var f Status_Detail
var list []Status_Detail
in.Delim('[')
for !in.IsDelim(']') {
f = new(Status_Detail)
f = Status_Detail{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()

View file

@ -15,9 +15,9 @@ import (
)
type Tombstone struct {
ExpirationEpoch uint64 `json:"expirationEpoch"`
SplitId []byte `json:"splitID"`
Members []*grpc.ObjectID `json:"members"`
ExpirationEpoch uint64 `json:"expirationEpoch"`
SplitId []byte `json:"splitID"`
Members []grpc.ObjectID `json:"members"`
}
var (
@ -37,7 +37,7 @@ func (x *Tombstone) StableSize() (size int) {
size += proto.UInt64Size(1, x.ExpirationEpoch)
size += proto.BytesSize(2, x.SplitId)
for i := range x.Members {
size += proto.NestedStructureSize(3, x.Members[i])
size += proto.NestedStructureSizeUnchecked(3, &x.Members[i])
}
return size
}
@ -62,9 +62,7 @@ func (x *Tombstone) EmitProtobuf(mm *easyproto.MessageMarshaler) {
mm.AppendBytes(2, x.SplitId)
}
for i := range x.Members {
if x.Members[i] != nil {
x.Members[i].EmitProtobuf(mm.AppendMessage(3))
}
x.Members[i].EmitProtobuf(mm.AppendMessage(3))
}
}
@ -94,8 +92,8 @@ func (x *Tombstone) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "Members")
}
x.Members = append(x.Members, new(grpc.ObjectID))
ff := x.Members[len(x.Members)-1]
x.Members = append(x.Members, grpc.ObjectID{})
ff := &x.Members[len(x.Members)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -121,13 +119,13 @@ func (x *Tombstone) GetSplitId() []byte {
func (x *Tombstone) SetSplitId(v []byte) {
x.SplitId = v
}
func (x *Tombstone) GetMembers() []*grpc.ObjectID {
func (x *Tombstone) GetMembers() []grpc.ObjectID {
if x != nil {
return x.Members
}
return nil
}
func (x *Tombstone) SetMembers(v []*grpc.ObjectID) {
func (x *Tombstone) SetMembers(v []grpc.ObjectID) {
x.Members = v
}
@ -207,11 +205,11 @@ func (x *Tombstone) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "members":
{
var f *grpc.ObjectID
var list []*grpc.ObjectID
var f grpc.ObjectID
var list []grpc.ObjectID
in.Delim('[')
for !in.IsDelim(']') {
f = new(grpc.ObjectID)
f = grpc.ObjectID{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()

View file

@ -133,10 +133,10 @@ func randIntSlice[T protoInt](n int, includeZero bool) []T {
return r
}
func uint32SliceToAux(s []uint32) []*generated.RepPrimitives_Aux {
r := make([]*generated.RepPrimitives_Aux, len(s))
func uint32SliceToAux(s []uint32) []generated.RepPrimitives_Aux {
r := make([]generated.RepPrimitives_Aux, len(s))
for i := range s {
r[i] = &generated.RepPrimitives_Aux{s[i]}
r[i] = generated.RepPrimitives_Aux{InnerField: s[i]}
}
return r
}

View file

@ -932,14 +932,14 @@ func (x *RepPrimitives_Aux) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
type RepPrimitives struct {
FieldA [][]byte `json:"fieldA"`
FieldB []string `json:"fieldB"`
FieldC []int32 `json:"fieldC"`
FieldD []uint32 `json:"fieldD"`
FieldE []int64 `json:"fieldE"`
FieldF []uint64 `json:"fieldF"`
FieldFu []uint64 `json:"fieldFu"`
FieldAux []*RepPrimitives_Aux `json:"fieldAux"`
FieldA [][]byte `json:"fieldA"`
FieldB []string `json:"fieldB"`
FieldC []int32 `json:"fieldC"`
FieldD []uint32 `json:"fieldD"`
FieldE []int64 `json:"fieldE"`
FieldF []uint64 `json:"fieldF"`
FieldFu []uint64 `json:"fieldFu"`
FieldAux []RepPrimitives_Aux `json:"fieldAux"`
}
var (
@ -971,7 +971,7 @@ func (x *RepPrimitives) StableSize() (size int) {
size += protowire.SizeGroup(protowire.Number(7), protowire.SizeVarint(x.FieldFu[i]))
}
for i := range x.FieldAux {
size += proto.NestedStructureSize(8, x.FieldAux[i])
size += proto.NestedStructureSizeUnchecked(8, &x.FieldAux[i])
}
return size
}
@ -1011,9 +1011,7 @@ func (x *RepPrimitives) EmitProtobuf(mm *easyproto.MessageMarshaler) {
mm.AppendUint64(7, x.FieldFu[j])
}
for i := range x.FieldAux {
if x.FieldAux[i] != nil {
x.FieldAux[i].EmitProtobuf(mm.AppendMessage(8))
}
x.FieldAux[i].EmitProtobuf(mm.AppendMessage(8))
}
}
@ -1073,8 +1071,8 @@ func (x *RepPrimitives) UnmarshalProtobuf(src []byte) (err error) {
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "FieldAux")
}
x.FieldAux = append(x.FieldAux, new(RepPrimitives_Aux))
ff := x.FieldAux[len(x.FieldAux)-1]
x.FieldAux = append(x.FieldAux, RepPrimitives_Aux{})
ff := &x.FieldAux[len(x.FieldAux)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
@ -1145,13 +1143,13 @@ func (x *RepPrimitives) GetFieldFu() []uint64 {
func (x *RepPrimitives) SetFieldFu(v []uint64) {
x.FieldFu = v
}
func (x *RepPrimitives) GetFieldAux() []*RepPrimitives_Aux {
func (x *RepPrimitives) GetFieldAux() []RepPrimitives_Aux {
if x != nil {
return x.FieldAux
}
return nil
}
func (x *RepPrimitives) SetFieldAux(v []*RepPrimitives_Aux) {
func (x *RepPrimitives) SetFieldAux(v []RepPrimitives_Aux) {
x.FieldAux = v
}
@ -1384,11 +1382,11 @@ func (x *RepPrimitives) UnmarshalEasyJSON(in *jlexer.Lexer) {
}
case "fieldAux":
{
var f *RepPrimitives_Aux
var list []*RepPrimitives_Aux
var f RepPrimitives_Aux
var list []RepPrimitives_Aux
in.Delim('[')
for !in.IsDelim(']') {
f = new(RepPrimitives_Aux)
f = RepPrimitives_Aux{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()

View file

@ -117,7 +117,7 @@ func emitJSONFieldRead(g *protogen.GeneratedFile, f *protogen.Field, name string
template = "%s = in.Bytes()"
case protoreflect.MessageKind:
if f.Desc.IsList() {
g.P("f = new(", fieldType(g, f)[3:], ")")
g.P("f = ", fieldType(g, f)[2:], "{}")
} else {
g.P("f = new(", fieldType(g, f)[1:], ")")
}

View file

@ -39,8 +39,8 @@ func emitFieldUnmarshal(g *protogen.GeneratedFile, f *protogen.Field) {
g.P("data, ok := fc.MessageData()")
g.P(`if !ok { return fmt.Errorf("cannot unmarshal field %s", "`, f.GoName, `") }`)
if f.Desc.IsList() {
g.P(name, " = append(", name, ", new(", fieldType(g, f)[3:], "))")
g.P("ff := ", name, "[len(", name, ")-1]")
g.P(name, " = append(", name, ", ", fieldType(g, f)[2:], "{})")
g.P("ff := &", name, "[len(", name, ")-1]")
name = "ff"
} else if f.Oneof != nil {
const tmp = "oneofField"
@ -172,11 +172,12 @@ func emitMarshalRaw(g *protogen.GeneratedFile, f *protogen.Field, name string) {
defer g.P("}")
name += "[i]"
} else {
g.P("if ", notNil(name), " {")
defer g.P("}")
}
g.P("if ", notNil(name), " {")
g.P(name, ".EmitProtobuf(mm.AppendMessage(", f.Desc.Number(), "))")
g.P("}")
return
}

View file

@ -43,7 +43,10 @@ func fieldType(g *protogen.GeneratedFile, field *protogen.Field) structField {
case protoreflect.BytesKind:
typ = "[]byte"
case protoreflect.MessageKind:
typ = structField(g.QualifiedGoIdent(field.Message.GoIdent)).PointerTo()
typ = structField(g.QualifiedGoIdent(field.Message.GoIdent))
if !field.Desc.IsList() {
typ = typ.PointerTo()
}
case protoreflect.GroupKind:
panic("unimplemented")
}

View file

@ -72,7 +72,7 @@ func emitFieldSize(g *protogen.GeneratedFile, f *protogen.Field) {
case f.Desc.IsList() && (f.Desc.Kind() == protoreflect.MessageKind || f.Desc.Kind() == protoreflect.Uint64Kind && !f.Desc.IsPacked()):
g.P("for i := range ", name, "{")
if f.Desc.Kind() == protoreflect.MessageKind {
g.P("size += ", protoPackage.Ident("NestedStructureSize"), "(", f.Desc.Number(), ", ", name, "[i])")
g.P("size += ", protoPackage.Ident("NestedStructureSizeUnchecked"), "(", f.Desc.Number(), ", &", name, "[i])")
} else {
if f.Desc.Kind() != protoreflect.Uint64Kind {
panic("only uint64 unpacked primitive is supported")