imay commented on a change in pull request #6625:
URL: https://github.com/apache/incubator-doris/pull/6625#discussion_r707273803



##########
File path: be/src/util/coding.h
##########
@@ -27,37 +27,37 @@ inline void encode_fixed8(uint8_t* buf, uint8_t val) {
 
 inline void encode_fixed16_le(uint8_t* buf, uint16_t val) {
 #if __BYTE_ORDER == __LITTLE_ENDIAN
-    memcpy(buf, &val, sizeof(val));
+    *(uint16_t*)buf = val;
 #else
     uint16_t res = bswap_16(val);
-    memcpy(buf, &res, sizeof(res));
+    *(uint16_t*)buf = res;
 #endif
 }
 
 inline void encode_fixed32_le(uint8_t* buf, uint32_t val) {
 #if __BYTE_ORDER == __LITTLE_ENDIAN
-    memcpy(buf, &val, sizeof(val));
+    *(uint32_t*)buf = val;
 #else
     uint32_t res = bswap_32(val);
-    memcpy(buf, &res, sizeof(res));
+    *(uint32_t*)buf = res;
 #endif
 }
 
 inline void encode_fixed64_le(uint8_t* buf, uint64_t val) {
 #if __BYTE_ORDER == __LITTLE_ENDIAN
-    memcpy(buf, &val, sizeof(val));
+    *(uint64_t*)buf = val;
 #else
     uint64_t res = gbswap_64(val);
-    memcpy(buf, &res, sizeof(res));
+    *(uint64_t*)buf = res;
 #endif
 }
 
 inline void encode_fixed128_le(uint8_t* buf, uint128_t val) {
 #if __BYTE_ORDER == __LITTLE_ENDIAN
-    memcpy(buf, &val, sizeof(val));
+    *(uint128_t*)buf = val;

Review comment:
       GCC will generate SIMD instruments, which needs address aligment. If 
address is not alignment, progress will throw illegal instruction exception




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to