summaryrefslogtreecommitdiffstats
path: root/common/entitybuffer.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-04-07 12:50:07 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-04-07 12:50:07 +0200
commitc00d5fb305abff370f869dec0e9404f8a4a5646b (patch)
tree12794ff568d272e7326f6502727443e7928cd64c /common/entitybuffer.h
parentb7873e621ef45badaa70e2d285998c486920df4a (diff)
downloadsink-c00d5fb305abff370f869dec0e9404f8a4a5646b.tar.gz
sink-c00d5fb305abff370f869dec0e9404f8a4a5646b.zip
Use memcpy to copy tables into vectors.
Ideally we wouldn't be copying at all, and somehow cast the table to a vector. Unfortunately I haven't figured out how to do that, and this solution at least gets us from 0.065 ms to 0.028 ms in testCreateCommand.
Diffstat (limited to 'common/entitybuffer.h')
-rw-r--r--common/entitybuffer.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/common/entitybuffer.h b/common/entitybuffer.h
index 097b450..f22c84e 100644
--- a/common/entitybuffer.h
+++ b/common/entitybuffer.h
@@ -15,7 +15,14 @@ public:
15 const Entity &entity(); 15 const Entity &entity();
16 16
17 static void extractResourceBuffer(void *dataValue, int dataSize, const std::function<void(const uint8_t *, size_t size)> &handler); 17 static void extractResourceBuffer(void *dataValue, int dataSize, const std::function<void(const uint8_t *, size_t size)> &handler);
18 /*
19 * TODO: Ideally we would be passing references to vectors in the same bufferbuilder, to avoid needlessly copying data.
20 * Unfortunately I couldn't find a way to cast a table to a vector<uint8_t> reference.
21 * We can't use union's either (which would allow to have a field that stores a selection of tables), as we don't want to modify
22 * the entity schema for each resource's buffers.
23 */
18 static void assembleEntityBuffer(flatbuffers::FlatBufferBuilder &fbb, void const *metadataData, size_t metadataSize, void const *resourceData, size_t resourceSize, void const *localData, size_t localSize); 24 static void assembleEntityBuffer(flatbuffers::FlatBufferBuilder &fbb, void const *metadataData, size_t metadataSize, void const *resourceData, size_t resourceSize, void const *localData, size_t localSize);
25 static flatbuffers::Offset<flatbuffers::Vector<uint8_t> > appendAsVector(flatbuffers::FlatBufferBuilder &fbb, void const *data, size_t size);
19 26
20private: 27private:
21 const Entity *mEntity; 28 const Entity *mEntity;