Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite encoding functions #1358

Merged
merged 2 commits into from
Mar 27, 2023
Merged

Conversation

PragmaTwice
Copy link
Member

We use if constexpr, __builtin_bswapN and __builtin_memcpy for better performance and maintainability.

image

@PragmaTwice PragmaTwice requested review from git-hulk and torwig March 27, 2023 13:36
Copy link
Member

@git-hulk git-hulk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, LGTM.

I saw the clang replace the memcpy with __builtin_memcpy in the underlying implementation but didn't check the GCC.

__DEVICE__ void *memcpy(void *__a, const void *__b, size_t __c) {
  return __builtin_memcpy(__a, __b, __c);
}


__builtin_memcpy(&value, ptr, sizeof(value));

return BYTE_ORDER == LITTLE_ENDIAN ? __builtin_bswap32(value) : value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PragmaTwice Is there a possibility to use if constexpr here with the condition? Or it wouldn't change anything?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if constexpr is just a constraint in this case. Compiler will eliminate constant conditions.

@PragmaTwice PragmaTwice merged commit 3f86bec into apache:unstable Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants