diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-05-16 00:21:24 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-06 07:16:10 +0200 |
commit | 1c598695e433b9ac65887d156fcd78b10e6269de (patch) | |
tree | 130382519419264296bea7a00349b8a7ba95ecf5 /sibs | |
parent | 8c486ac721e590b18650abaaa8a69b36dbcba806 (diff) |
Optimize for little endian instead of big endian
Diffstat (limited to 'sibs')
-rw-r--r-- | sibs/SafeDeserializer.hpp | 4 | ||||
-rw-r--r-- | sibs/SafeSerializer.hpp | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/sibs/SafeDeserializer.hpp b/sibs/SafeDeserializer.hpp index 7ef6b3f..0110920 100644 --- a/sibs/SafeDeserializer.hpp +++ b/sibs/SafeDeserializer.hpp @@ -38,7 +38,7 @@ namespace sibs verifyExtractSize(typeSize); size -= typeSize; T result; - #ifdef LITTLE_ENDIAN + #if BYTE_ORDER == BIG_ENDIAN switch(typeSize) { case 1: @@ -63,7 +63,7 @@ namespace sibs } } #else - memcpy(&result, data, typeSize); + result = *(T*)data; #endif data += typeSize; return result; diff --git a/sibs/SafeSerializer.hpp b/sibs/SafeSerializer.hpp index 72ef5a3..379b7c8 100644 --- a/sibs/SafeSerializer.hpp +++ b/sibs/SafeSerializer.hpp @@ -22,7 +22,7 @@ namespace sibs { usize offset = buffer.size(); buffer.resize(buffer.size() + sizeof(T)); - #ifdef LITTLE_ENDIAN + #if BYTE_ORDER == BIG_ENDIAN switch(sizeof(T)) { case 1: @@ -47,7 +47,7 @@ namespace sibs } } #else - memcpy(&buffer[offset], &data, sizeof(T)); + *(T*)&buffer[offset] = data; #endif } |