summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorTGIshib <justzeddicus@gmail.com>2016-08-26 19:41:32 +0300
committerTGIshib <justzeddicus@gmail.com>2016-08-26 19:41:32 +0300
commit7c69c5dc3d635e29e3442339caa8eb06b8b9775c (patch)
treef29985abd8b044f198629504161fa37000f8cd37 /net
parent9f16090f901c30f872422f60db21a0370dde8bbf (diff)
downloadflatbuffers-7c69c5dc3d635e29e3442339caa8eb06b8b9775c.tar.gz
flatbuffers-7c69c5dc3d635e29e3442339caa8eb06b8b9775c.tar.bz2
flatbuffers-7c69c5dc3d635e29e3442339caa8eb06b8b9775c.zip
Fix lookupByKey, improve compareStrings
Diffstat (limited to 'net')
-rw-r--r--net/FlatBuffers/Table.cs20
1 files changed, 9 insertions, 11 deletions
diff --git a/net/FlatBuffers/Table.cs b/net/FlatBuffers/Table.cs
index 20f41f6f..ca52d7d0 100644
--- a/net/FlatBuffers/Table.cs
+++ b/net/FlatBuffers/Table.cs
@@ -125,30 +125,28 @@ 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 (bb.Data[i + startPos_1] != bb.Data[i + startPos_2])
- return bb.Data[i + startPos_1] - bb.Data[i + startPos_2];
+ if (bbArray[i + startPos_1] != bbArray[i + startPos_2])
+ return bbArray[i + startPos_1] - bbArray[i + startPos_2];
}
- if (len_1 < len_2) return -1;
- if (len_1 > len_2) return 1;
- return 0;
+ return len_1 - len_2;
}
// Compare string from the ByteBuffer with the string object
- protected static int CompareStrings(int offset_1, string key, ByteBuffer bb)
+ protected static int CompareStrings(int offset_1, byte[] key, ByteBuffer bb)
{
offset_1 += bb.GetInt(offset_1);
var len_1 = bb.GetInt(offset_1);
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 (bb.Data[i + startPos_1] != key[i])
- return bb.Data[i + startPos_1] - key[i];
+ if (bbArray[i + startPos_1] != key[i])
+ return bbArray[i + startPos_1] - key[i];
}
- if (len_1 < len_2) return -1;
- if (len_1 > len_2) return 1;
- return 0;
+ return len_1 - len_2;
}
}