use less memcpy in dataArg

This commit is contained in:
lyon 2022-01-14 13:34:20 +08:00
parent c16af7b13b
commit e8186ec80d

View File

@ -85,8 +85,8 @@ uint8_t* content_init_hash(Hash nameHash,
uint8_t* contentDir = nameDir + nameSize; uint8_t* contentDir = nameDir + nameSize;
uint8_t* typeDir = contentDir + size; uint8_t* typeDir = contentDir + size;
__platform_memcpy(nameDir, &nameHash, nameSize); // use hash *(Hash*)nameDir = nameHash;
__platform_memcpy(typeDir, &type, typeSize); *(ArgType*)typeDir = type;
uint32_t* p_size = (uint32_t*)sizeDir; uint32_t* p_size = (uint32_t*)sizeDir;
*p_size = size; *p_size = size;
if (NULL != content) { if (NULL != content) {
@ -217,10 +217,9 @@ Arg* arg_setType(Arg* self, ArgType type) {
} }
ArgType content_getType(uint8_t* self) { ArgType content_getType(uint8_t* self) {
void* type_ptr = (uint8_t*)self + content_typeOffset(self); ArgType* type_ptr =
ArgType type; (ArgType*)((uintptr_t)self + (uintptr_t)content_typeOffset(self));
__platform_memcpy(&type, type_ptr, sizeof(ArgType)); return *type_ptr;
return type;
} }
uint16_t content_contentOffset(uint8_t* self) { uint16_t content_contentOffset(uint8_t* self) {