mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Use pre-allocated array sizes and packed where possible in intl
This commit is contained in:
parent
68b904884b
commit
e9b01f202b
4 changed files with 14 additions and 7 deletions
|
@ -469,7 +469,8 @@ PHP_FUNCTION( collator_sort_with_sort_keys )
|
|||
|
||||
ZVAL_COPY_VALUE(&garbage, array);
|
||||
/* for resulting hash we'll assign new hash keys rather then reordering */
|
||||
array_init(array);
|
||||
array_init_size(array, sortKeyCount);
|
||||
zend_hash_real_init_packed(Z_ARRVAL_P(array));
|
||||
|
||||
for( j = 0; j < sortKeyCount; j++ )
|
||||
{
|
||||
|
|
|
@ -294,7 +294,8 @@ static void php_converter_from_u_callback(const void *context,
|
|||
zval zargs[4];
|
||||
|
||||
ZVAL_LONG(&zargs[0], reason);
|
||||
array_init(&zargs[1]);
|
||||
array_init_size(&zargs[1], length);
|
||||
zend_hash_real_init_packed(Z_ARRVAL(zargs[1]));
|
||||
int i = 0;
|
||||
while (i < length) {
|
||||
UChar32 c;
|
||||
|
@ -807,7 +808,8 @@ PHP_METHOD(UConverter, getAvailable) {
|
|||
|
||||
intl_error_reset(NULL);
|
||||
|
||||
array_init(return_value);
|
||||
array_init_size(return_value, count);
|
||||
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
|
||||
for(i = 0; i < count; i++) {
|
||||
const char *name = ucnv_getAvailableName(i);
|
||||
add_next_index_string(return_value, name);
|
||||
|
@ -833,7 +835,8 @@ PHP_METHOD(UConverter, getAliases) {
|
|||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
array_init(return_value);
|
||||
array_init_size(return_value, count);
|
||||
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
|
||||
for(i = 0; i < count; i++) {
|
||||
const char *alias;
|
||||
|
||||
|
@ -856,8 +859,9 @@ PHP_METHOD(UConverter, getStandards) {
|
|||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
intl_error_reset(NULL);
|
||||
|
||||
array_init(return_value);
|
||||
count = ucnv_countStandards();
|
||||
array_init_size(return_value, count);
|
||||
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
|
||||
for(i = 0; i < count; i++) {
|
||||
UErrorCode error = U_ZERO_ERROR;
|
||||
const char *name = ucnv_getStandard(i, &error);
|
||||
|
|
|
@ -42,7 +42,8 @@ static void msgfmt_do_parse(MessageFormatter_object *mfo, char *source, size_t s
|
|||
}
|
||||
INTL_METHOD_CHECK_STATUS(mfo, "Parsing failed");
|
||||
|
||||
array_init(return_value);
|
||||
array_init_size(return_value, count);
|
||||
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
|
||||
for(i=0;i<count;i++) {
|
||||
add_next_index_zval(return_value, &fargs[i]);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,8 @@ void resourcebundle_extract_value( zval *return_value, ResourceBundle_object *so
|
|||
case URES_INT_VECTOR:
|
||||
vfield = ures_getIntVector( source->child, &ilen, &INTL_DATA_ERROR_CODE(source) );
|
||||
INTL_METHOD_CHECK_STATUS(source, "Failed to retrieve vector value");
|
||||
array_init( return_value );
|
||||
array_init_size( return_value, ilen );
|
||||
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
|
||||
for (i=0; i<ilen; i++) {
|
||||
add_next_index_long( return_value, vfield[i] );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue