Preallocate a GPtrArray to avoid some reallocations later on

Suggested by Georges Basile Stavracas Neto.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2018-08-16 15:44:09 +01:00
parent a44329c244
commit 084e1d8680

View File

@ -462,7 +462,7 @@ gvdb_table_get_names (GvdbTable *table,
{ {
GPtrArray *fixed_names; GPtrArray *fixed_names;
fixed_names = g_ptr_array_new (); fixed_names = g_ptr_array_sized_new (n_names);
for (i = 0; i < n_names; i++) for (i = 0; i < n_names; i++)
if (names[i] != NULL) if (names[i] != NULL)
g_ptr_array_add (fixed_names, names[i]); g_ptr_array_add (fixed_names, names[i]);