mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-09 06:30:54 +00:00
fix CScript string.compare (#8547)
* fix CScript string.compare Because the default compare sorting rules of c# string are different from those of cpp, the binary file exported by flatc -b cannot use LookupByKey * run generate_code.py ---------
This commit is contained in:
@@ -521,7 +521,7 @@ public struct Monster : IFlatbufferObject
|
||||
public static VectorOffset CreateSortedVectorOfMonster(FlatBufferBuilder builder, Offset<Monster>[] offsets) {
|
||||
Array.Sort(offsets,
|
||||
(Offset<Monster> o1, Offset<Monster> o2) =>
|
||||
new Monster().__assign(builder.DataBuffer.Length - o1.Value, builder.DataBuffer).Name.CompareTo(new Monster().__assign(builder.DataBuffer.Length - o2.Value, builder.DataBuffer).Name));
|
||||
string.CompareOrdinal(new Monster().__assign(builder.DataBuffer.Length - o1.Value, builder.DataBuffer).Name, new Monster().__assign(builder.DataBuffer.Length - o2.Value, builder.DataBuffer).Name));
|
||||
return builder.CreateVectorOfTables(offsets);
|
||||
}
|
||||
|
||||
@@ -533,7 +533,7 @@ public struct Monster : IFlatbufferObject
|
||||
int middle = span / 2;
|
||||
int tableOffset = Table.__indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
obj_.__assign(tableOffset, bb);
|
||||
int comp = obj_.Name.CompareTo(key);
|
||||
int comp = string.CompareOrdinal(obj_.Name, key);
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
|
||||
Reference in New Issue
Block a user