Skip to content

tree-wide: Refactor with zend_string_ends_with* - #23216

Open
LamentXU123 wants to merge 1 commit into
php:masterfrom
LamentXU123:zend_str_ends
Open

tree-wide: Refactor with zend_string_ends_with*#23216
LamentXU123 wants to merge 1 commit into
php:masterfrom
LamentXU123:zend_str_ends

Conversation

@LamentXU123

Copy link
Copy Markdown
Member

Utilize zend_string_ends_with* APIs added in #22819.

@NattyNarwhal NattyNarwhal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ok odbc

@jorgsowa jorgsowa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good for ext/session

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor nits really

Comment on lines +1522 to +1523
return filename && ZSTR_LEN(filename) > sizeof(".phar") - 1 &&
zend_string_ends_with_literal(filename, ".phar") &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You no longer need the ZSTR_LEN comparison, as that's taken care of by zend_string_ends_with_literal

Comment thread ext/pgsql/pgsql.c

int result;
if (ZSTR_LEN(tmp) > 0 && ZSTR_VAL(tmp)[ZSTR_LEN(tmp) - 1] != '\n') {
if (ZSTR_LEN(tmp) > 0 && !zend_string_ends_with_literal(tmp, "\n")) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ditto

Comment thread ext/soap/php_http.c
} else {
return false;
}
return ZSTR_LEN(host) > ZSTR_LEN(domain) && zend_string_ends_with(host, domain);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ditto

Comment thread ext/json/json_encoder.c
}

bool empty = ZSTR_VAL(buf->s)[ZSTR_LEN(buf->s) - 1] != ',';
bool empty = !zend_string_ends_with_literal(buf->s, ",");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are these calls inlined? As this might have a performance impact? (Mainly asking as I know some work was done to improve the performance of the encoder recently)

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.

5 participants