Skip to content

Commit a7a3a5f

Browse files
authored
zend_ast: Clean up zend_ast_export_quoted_str() (php#22393)
* zend_ast: Make `s` a `const zend_string*` in `zend_ast_export_quoted_str()` Following php#22350. * zend_ast: Reduce variable scope in `zend_ast_export_*str()`
1 parent cb64c16 commit a7a3a5f

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

Zend/zend_ast.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,9 +1578,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
15781578

15791579
static ZEND_COLD void zend_ast_export_str(smart_str *str, const zend_string *s)
15801580
{
1581-
size_t i;
1582-
1583-
for (i = 0; i < ZSTR_LEN(s); i++) {
1581+
for (size_t i = 0; i < ZSTR_LEN(s); i++) {
15841582
unsigned char c = ZSTR_VAL(s)[i];
15851583
if (c == '\'' || c == '\\') {
15861584
smart_str_appendc(str, '\\');
@@ -1593,9 +1591,7 @@ static ZEND_COLD void zend_ast_export_str(smart_str *str, const zend_string *s)
15931591

15941592
static ZEND_COLD void zend_ast_export_qstr(smart_str *str, char quote, const zend_string *s)
15951593
{
1596-
size_t i;
1597-
1598-
for (i = 0; i < ZSTR_LEN(s); i++) {
1594+
for (size_t i = 0; i < ZSTR_LEN(s); i++) {
15991595
unsigned char c = ZSTR_VAL(s)[i];
16001596
if (c < ' ') {
16011597
switch (c) {
@@ -1636,12 +1632,11 @@ static ZEND_COLD void zend_ast_export_qstr(smart_str *str, char quote, const zen
16361632
}
16371633
}
16381634

1639-
static ZEND_COLD void zend_ast_export_quoted_str(smart_str *str, zend_string *s)
1635+
static ZEND_COLD void zend_ast_export_quoted_str(smart_str *str, const zend_string *s)
16401636
{
1641-
size_t i;
1642-
1643-
for (i = 0; i < ZSTR_LEN(s); i++) {
1644-
if ((unsigned char) ZSTR_VAL(s)[i] < ' ') {
1637+
for (size_t i = 0; i < ZSTR_LEN(s); i++) {
1638+
unsigned char c = ZSTR_VAL(s)[i];
1639+
if (c < ' ') {
16451640
smart_str_appendc(str, '"');
16461641
zend_ast_export_qstr(str, '"', s);
16471642
smart_str_appendc(str, '"');

0 commit comments

Comments
 (0)