diff options
Diffstat (limited to 'net/FlatBuffers/Table.cs')
-rw-r--r-- | net/FlatBuffers/Table.cs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/net/FlatBuffers/Table.cs b/net/FlatBuffers/Table.cs index 55182b38..4a188ff8 100644 --- a/net/FlatBuffers/Table.cs +++ b/net/FlatBuffers/Table.cs @@ -60,7 +60,7 @@ namespace FlatBuffers offset += bb.GetInt(offset); var len = bb.GetInt(offset); var startPos = offset + sizeof(int); - return Encoding.UTF8.GetString(bb.Data, startPos , len); + return bb.GetStringUTF8(startPos, len); } // Get the length of a vector whose offset is stored at "offset" in this object. @@ -91,7 +91,7 @@ namespace FlatBuffers var pos = this.__vector(o); var len = this.__vector_len(o); - return new ArraySegment<byte>(this.bb.Data, pos, len); + return bb.ToArraySegment(pos, len); } // Initialize any Table-derived type to point to the union at the given offset. @@ -126,10 +126,11 @@ namespace FlatBuffers var startPos_1 = offset_1 + sizeof(int); var startPos_2 = offset_2 + sizeof(int); var len = Math.Min(len_1, len_2); - byte[] bbArray = bb.Data; for(int i = 0; i < len; i++) { - if (bbArray[i + startPos_1] != bbArray[i + startPos_2]) - return bbArray[i + startPos_1] - bbArray[i + startPos_2]; + byte b1 = bb.Get(i + startPos_1); + byte b2 = bb.Get(i + startPos_2); + if (b1 != b2) + return b1 - b2; } return len_1 - len_2; } @@ -142,10 +143,10 @@ namespace FlatBuffers var len_2 = key.Length; var startPos_1 = offset_1 + sizeof(int); var len = Math.Min(len_1, len_2); - byte[] bbArray = bb.Data; for (int i = 0; i < len; i++) { - if (bbArray[i + startPos_1] != key[i]) - return bbArray[i + startPos_1] - key[i]; + byte b = bb.Get(i + startPos_1); + if (b != key[i]) + return b - key[i]; } return len_1 - len_2; } |