mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-05 23:36:53 +00:00
Avoid memcpy call for empty vectors (#6111)
Co-authored-by: kuddai <kuddai92@gmail.com>
This commit is contained in:
@@ -1607,6 +1607,9 @@ class FlatBufferBuilder {
|
|||||||
// causing the wrong overload to be selected, remove it.
|
// causing the wrong overload to be selected, remove it.
|
||||||
AssertScalarT<T>();
|
AssertScalarT<T>();
|
||||||
StartVector(len, sizeof(T));
|
StartVector(len, sizeof(T));
|
||||||
|
if (len == 0) {
|
||||||
|
return Offset<Vector<T>>(EndVector(len));
|
||||||
|
}
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#if FLATBUFFERS_LITTLEENDIAN
|
#if FLATBUFFERS_LITTLEENDIAN
|
||||||
PushBytes(reinterpret_cast<const uint8_t *>(v), len * sizeof(T));
|
PushBytes(reinterpret_cast<const uint8_t *>(v), len * sizeof(T));
|
||||||
|
|||||||
Reference in New Issue
Block a user