Skip to content

ext/snmp: use memcpy() instead of memmove() #10498

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

Merged
merged 1 commit into from
Feb 5, 2023
Merged

Conversation

MaxKellermann
Copy link
Contributor

memcpy() may be faster because it does not have to consider overlapping buffers.

memcpy() may be faster because it does not have to consider
overlapping buffers.
@devnexen
Copy link
Member

devnexen commented Feb 4, 2023

From a good glance, it seems unnecessary to use memmove in those places indeed, even tough memcpy is not systematically faster, despite the overlap checks so there might be not necessarily a huge win, if there is. When the feature had been rewritten around php 5.5 memmove was still kept, so do not know if it was overlooked or if there is a good reason we just do not see. Saying that I do not oppose the changes neither, but let's see what @Girgias has to say about this.

@MaxKellermann
Copy link
Contributor Author

not necessarily a huge win

True. It's a tiny tiny micro optimization only there to omit the overlap check.

As a compiler implementation detail, the compiler can decide to inline memcpy() more easily than memmove(), because the simplest version of memcpy() is just a single instruction (REP MOVS), while the simplest version of memmove() is much larger than that.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

I don't see how the memory can overlap here

@Girgias Girgias merged commit d3abcae into php:master Feb 5, 2023
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Feb 14, 2023
memcpy() may be faster because it does not have to consider
overlapping buffers.
@MaxKellermann MaxKellermann deleted the memcpy branch March 7, 2023 13:25
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Mar 7, 2023
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Mar 14, 2023
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Apr 12, 2023
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request May 16, 2023
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Jun 16, 2023
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Jul 19, 2023
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Aug 1, 2023
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Aug 3, 2023
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Aug 3, 2023
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Aug 30, 2023
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Oct 2, 2023
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Nov 24, 2023
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Jan 17, 2024
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Jan 17, 2024
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Feb 23, 2024
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Mar 15, 2024
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Apr 15, 2024
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request May 8, 2024
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Jun 5, 2024
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Jul 3, 2024
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Jul 30, 2024
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Aug 28, 2024
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Oct 15, 2024
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Oct 30, 2024
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Nov 20, 2024
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Jan 7, 2025
memcpy() may be faster because it does not have to consider
overlapping buffers.
MaxKellermann added a commit to CM4all/php-src that referenced this pull request Mar 11, 2025
memcpy() may be faster because it does not have to consider
overlapping buffers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants