Skip to content

Commit

Permalink
Improved array writing speed
Browse files Browse the repository at this point in the history
  • Loading branch information
marcizhu committed Apr 1, 2017
1 parent 6729d89 commit edd9dab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 1 addition & 2 deletions Cereal/Cereal/src/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ namespace Cereal {
else
s = size;

for (unsigned int i = 0; i < s; i++)
buffer.writeBytes<byte>(data[i]);
buffer.copy(data, s);

return true;
}
Expand Down
9 changes: 9 additions & 0 deletions Cereal/Cereal/src/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ namespace Cereal {
return true;
}

bool copy(byte* data, unsigned int size)
{
memcpy((byte*)start + offset, data, size);

offset += size;

return true;
}

void shrink()
{
byte* temp = new byte[offset];
Expand Down
2 changes: 1 addition & 1 deletion Sandbox/Sandbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void testCereal64()
void testRead()
{
Cereal::Buffer buffer(0);
bool ret = buffer.readFile("C:\\Users\\marci\\Documents\\Visual Studio 2015\\Projects\\Cereal\\Debug\\test-out.db");
bool ret = buffer.readFile("test-out.db");
PT_ASSERT(ret == true);

Cereal::Header* header = new Cereal::Header;
Expand Down

0 comments on commit edd9dab

Please sign in to comment.