mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-09 14:46:26 +00:00
Remove all string allocations during parsing.
Change the signature for 'string' getters and settings to use byte slices instead of strings.
This commit is contained in:
@@ -50,12 +50,12 @@ func (rcv *Monster) Hp() int16 {
|
||||
return 100
|
||||
}
|
||||
|
||||
func (rcv *Monster) Name() string {
|
||||
func (rcv *Monster) Name() []byte {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(10))
|
||||
if o != 0 {
|
||||
return rcv._tab.String(o + rcv._tab.Pos)
|
||||
return rcv._tab.ByteVector(o + rcv._tab.Pos)
|
||||
}
|
||||
return ""
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rcv *Monster) Inventory(j int) byte {
|
||||
@@ -130,13 +130,13 @@ func (rcv *Monster) Test4Length() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (rcv *Monster) Testarrayofstring(j int) string {
|
||||
func (rcv *Monster) Testarrayofstring(j int) []byte {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(24))
|
||||
if o != 0 {
|
||||
a := rcv._tab.Vector(o)
|
||||
return rcv._tab.String(a + flatbuffers.UOffsetT(j * 4))
|
||||
return rcv._tab.ByteVector(a + flatbuffers.UOffsetT(j * 4))
|
||||
}
|
||||
return ""
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rcv *Monster) TestarrayofstringLength() int {
|
||||
@@ -148,9 +148,7 @@ func (rcv *Monster) TestarrayofstringLength() int {
|
||||
}
|
||||
|
||||
/// an example documentation comment: this will end up in the generated code
|
||||
|
||||
/// multiline too
|
||||
|
||||
func (rcv *Monster) Testarrayoftables(obj *Monster, j int) bool {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(26))
|
||||
if o != 0 {
|
||||
|
||||
@@ -14,12 +14,12 @@ func (rcv *Stat) Init(buf []byte, i flatbuffers.UOffsetT) {
|
||||
rcv._tab.Pos = i
|
||||
}
|
||||
|
||||
func (rcv *Stat) Id() string {
|
||||
func (rcv *Stat) Id() []byte {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
|
||||
if o != 0 {
|
||||
return rcv._tab.String(o + rcv._tab.Pos)
|
||||
return rcv._tab.ByteVector(o + rcv._tab.Pos)
|
||||
}
|
||||
return ""
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rcv *Stat) Val() int64 {
|
||||
|
||||
Reference in New Issue
Block a user