Skip to content

Commit ab99161

Browse files
committed
ext/standard/versioning.c: Slightly refactor compare_special_version_forms()
1 parent 8109d21 commit ab99161

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

ext/standard/versioning.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,36 +77,36 @@ php_canonicalize_version(const char *version)
7777

7878
typedef struct {
7979
const char *name;
80+
uint8_t name_len;
8081
int order;
8182
} special_forms_t;
8283

83-
static int
84-
compare_special_version_forms(char *form1, char *form2)
84+
static int compare_special_version_forms(char *form1, char *form2)
8585
{
8686
int found1 = -1, found2 = -1;
8787
special_forms_t special_forms[11] = {
88-
{"dev", 0},
89-
{"alpha", 1},
90-
{"a", 1},
91-
{"beta", 2},
92-
{"b", 2},
93-
{"RC", 3},
94-
{"rc", 3},
95-
{"#", 4},
96-
{"pl", 5},
97-
{"p", 5},
98-
{NULL, 0},
88+
{ZEND_STRL("dev"), 0},
89+
{ZEND_STRL("alpha"), 1},
90+
{ZEND_STRL("a"), 1},
91+
{ZEND_STRL("beta"), 2},
92+
{ZEND_STRL("b"), 2},
93+
{ZEND_STRL("RC"), 3},
94+
{ZEND_STRL("rc"), 3},
95+
{ZEND_STRL("#"), 4},
96+
{ZEND_STRL("pl"), 5},
97+
{ZEND_STRL("p"), 5},
98+
{NULL, 0, 0},
9999
};
100100
special_forms_t *pp;
101101

102102
for (pp = special_forms; pp && pp->name; pp++) {
103-
if (strncmp(form1, pp->name, strlen(pp->name)) == 0) {
103+
if (strncmp(form1, pp->name, pp->name_len) == 0) {
104104
found1 = pp->order;
105105
break;
106106
}
107107
}
108108
for (pp = special_forms; pp && pp->name; pp++) {
109-
if (strncmp(form2, pp->name, strlen(pp->name)) == 0) {
109+
if (strncmp(form2, pp->name, pp->name_len) == 0) {
110110
found2 = pp->order;
111111
break;
112112
}

0 commit comments

Comments
 (0)