summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDanila Kutenin <kutdanila@yandex.ru>2022-01-14 23:37:27 +0000
committerGitHub <noreply@github.com>2022-01-14 15:37:27 -0800
commitd7b75417fc21b981ba2a67c3ffca9e0796268b25 (patch)
treef341fc40d93002eb17e7a9f9c3650126f3ae33de /include
parenta42e898979cc828a35aefcc469fec896175fa8e6 (diff)
downloadflatbuffers-d7b75417fc21b981ba2a67c3ffca9e0796268b25.tar.gz
flatbuffers-d7b75417fc21b981ba2a67c3ffca9e0796268b25.tar.bz2
flatbuffers-d7b75417fc21b981ba2a67c3ffca9e0796268b25.zip
Make flatbuffer builder deterministic (#6993)
Diffstat (limited to 'include')
-rw-r--r--include/flatbuffers/flatbuffer_builder.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/flatbuffers/flatbuffer_builder.h b/include/flatbuffers/flatbuffer_builder.h
index 8be4efbe..5837cc6f 100644
--- a/include/flatbuffers/flatbuffer_builder.h
+++ b/include/flatbuffers/flatbuffer_builder.h
@@ -922,7 +922,7 @@ class FlatBufferBuilder {
/// where the vector is stored.
template<typename T>
Offset<Vector<const T *>> CreateVectorOfSortedStructs(T *v, size_t len) {
- std::sort(v, v + len, StructKeyComparator<T>());
+ std::stable_sort(v, v + len, StructKeyComparator<T>());
return CreateVectorOfStructs(v, len);
}
@@ -941,7 +941,7 @@ class FlatBufferBuilder {
extern T Pack(const S &);
auto structs = StartVectorOfStructs<T>(len);
for (size_t i = 0; i < len; i++) { structs[i] = Pack(v[i]); }
- std::sort(structs, structs + len, StructKeyComparator<T>());
+ std::stable_sort(structs, structs + len, StructKeyComparator<T>());
return EndVectorOfStructs<T>(len);
}
@@ -973,7 +973,7 @@ class FlatBufferBuilder {
template<typename T>
Offset<Vector<Offset<T>>> CreateVectorOfSortedTables(Offset<T> *v,
size_t len) {
- std::sort(v, v + len, TableKeyComparator<T>(buf_));
+ std::stable_sort(v, v + len, TableKeyComparator<T>(buf_));
return CreateVector(v, len);
}