Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ext/intl/collator/collator_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice I did not know this optimisation


for( j = 0; j < sortKeyCount; j++ )
{
Expand Down
12 changes: 8 additions & 4 deletions ext/intl/converter/converter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;

Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion ext/intl/msgformat/msgformat_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
3 changes: 2 additions & 1 deletion ext/intl/resourcebundle/resourcebundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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] );
}
Expand Down
Loading