You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2021/09/13 09:08:48 UTC
[GitHub] [incubator-doris] imay commented on a change in pull request #6625: hll optimize
imay commented on a change in pull request #6625:
URL: https://github.com/apache/incubator-doris/pull/6625#discussion_r707145902
##########
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:
better to use memcpy. If buf address is not aligned, this will cause BE crash.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org