Skip to content

Improve performance of unpack() with nameless repetitions #18803

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 3 commits into from
Jun 10, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
swap condition
  • Loading branch information
nielsdos committed Jun 10, 2025
commit e192e7cbe5b27fa679e17ade59e612588a417a10
8 changes: 4 additions & 4 deletions ext/standard/pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,12 +888,12 @@ PHP_FUNCTION(unpack)
zend_long long_key = 0;
zval val;

if (repetitions == 1 && namelen > 0) {
/* Use a part of the formatarg argument directly as the name. */
real_name = zend_string_init_fast(name, namelen);
} else if (namelen == 0) {
if (namelen == 0) {
real_name = NULL;
long_key = i + 1;
} else if (repetitions == 1) {
/* Use a part of the formatarg argument directly as the name. */
real_name = zend_string_init_fast(name, namelen);
} else {
/* Need to add the 1-based element number to the name */
char buf[MAX_LENGTH_OF_LONG + 1];
Expand Down