Skip to content

Commit bd8c770

Browse files
authored
ext/sqlite3: querySingle amd fetchArray methods optimisations. (php#18385)
pre-allocated size for the former and packed array.
1 parent df39586 commit bd8c770

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ext/sqlite3/sqlite3.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -701,9 +701,10 @@ PHP_METHOD(SQLite3, querySingle)
701701
if (!entire_row) {
702702
sqlite_value_to_zval(stmt, 0, return_value);
703703
} else {
704-
int i = 0;
705-
array_init(return_value);
706-
for (i = 0; i < sqlite3_data_count(stmt); i++) {
704+
int i = 0, count = sqlite3_data_count(stmt);
705+
706+
array_init_size(return_value, count);
707+
for (i = 0; i < count; i++) {
707708
zval data;
708709
sqlite_value_to_zval(stmt, i, &data);
709710
add_assoc_zval(return_value, (char*)sqlite3_column_name(stmt, i), &data);

0 commit comments

Comments
 (0)