Skip to content

Commit dfd4f2f

Browse files
committed
ext/intl: reuse known string lengths
1 parent f856ce0 commit dfd4f2f

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

ext/intl/locale/locale_methods.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ static zend_string* get_icu_value_internal( const char* loc_name , const char* t
457457
efree( mod_loc_name);
458458
}
459459

460-
tag_value->len = strlen(tag_value->val);
460+
tag_value->len = buflen;
461461
return tag_value;
462462
}
463463
/* }}} */
@@ -736,7 +736,7 @@ U_CFUNC PHP_FUNCTION( locale_get_keywords )
736736
Z_PARAM_PATH(loc_name, loc_name_len)
737737
ZEND_PARSE_PARAMETERS_END();
738738

739-
INTL_CHECK_LOCALE_LEN(strlen(loc_name));
739+
INTL_CHECK_LOCALE_LEN(loc_name_len);
740740

741741
if(loc_name_len == 0) {
742742
loc_name = (char *)intl_locale_get_default();
@@ -1127,7 +1127,7 @@ U_CFUNC PHP_FUNCTION(locale_parse)
11271127
Z_PARAM_PATH(loc_name, loc_name_len)
11281128
ZEND_PARSE_PARAMETERS_END();
11291129

1130-
INTL_CHECK_LOCALE_LEN(strlen(loc_name));
1130+
INTL_CHECK_LOCALE_LEN(loc_name_len);
11311131

11321132
if(loc_name_len == 0) {
11331133
loc_name = (char *)intl_locale_get_default();
@@ -1318,7 +1318,7 @@ U_CFUNC PHP_FUNCTION(locale_filter_matches)
13181318

13191319
if( token && (token==cur_lang_tag) ){
13201320
/* check if the char. after match is SEPARATOR */
1321-
chrcheck = token + (strlen(cur_loc_range));
1321+
chrcheck = token + can_loc_range->len;
13221322
if( isIDSeparator(*chrcheck) || isKeywordSeparator(*chrcheck) || isEndOfTag(*chrcheck) ){
13231323
efree( cur_lang_tag );
13241324
efree( cur_loc_range );
@@ -1350,14 +1350,14 @@ U_CFUNC PHP_FUNCTION(locale_filter_matches)
13501350
} /* end of if isCanonical */
13511351
else{
13521352
/* Convert to lower case for case-insensitive comparison */
1353-
cur_lang_tag = reinterpret_cast<char *>(ecalloc( 1, strlen(lang_tag ) + 1));
1353+
cur_lang_tag = reinterpret_cast<char *>(ecalloc(1, lang_tag_len + 1));
13541354

13551355
result = strToMatch( lang_tag , cur_lang_tag);
13561356
if( result == 0) {
13571357
efree( cur_lang_tag );
13581358
RETURN_FALSE;
13591359
}
1360-
cur_loc_range = reinterpret_cast<char *>(ecalloc( 1, strlen(loc_range ) + 1));
1360+
cur_loc_range = reinterpret_cast<char *>(ecalloc(1, loc_range_len + 1));
13611361
result = strToMatch( loc_range , cur_loc_range );
13621362
if( result == 0) {
13631363
efree( cur_lang_tag );
@@ -1370,7 +1370,7 @@ U_CFUNC PHP_FUNCTION(locale_filter_matches)
13701370

13711371
if( token && (token==cur_lang_tag) ){
13721372
/* check if the char. after match is SEPARATOR */
1373-
chrcheck = token + (strlen(cur_loc_range));
1373+
chrcheck = token + loc_range_len;
13741374
if( isIDSeparator(*chrcheck) || isEndOfTag(*chrcheck) ){
13751375
efree( cur_lang_tag );
13761376
efree( cur_loc_range );

0 commit comments

Comments
 (0)