Skip to content

Commit 7929820

Browse files
committed
Microoptimize port validation
1 parent 1f3f561 commit 7929820

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

ext/uri/uri_parser_rfc3986.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -760,11 +760,10 @@ ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_host(const ze
760760

761761
ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_port(const zend_long port)
762762
{
763-
zend_string *tmp = zend_long_to_str(port);
764-
const char *p = ZSTR_VAL(tmp);
765-
const size_t len = ZSTR_LEN(tmp);
766-
const bool well_formed = uriIsWellFormedPortA(p, p + len);
767-
zend_string_release(tmp);
763+
char buf[MAX_LENGTH_OF_LONG + 1];
764+
const char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, port);
765+
766+
const bool well_formed = uriIsWellFormedPortA(res, res + strlen(res));
768767

769768
return php_uri_parser_rfc3986_validate_component_result(well_formed, "port");
770769
}

0 commit comments

Comments
 (0)