mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
gdatalist: remove restriction of number of keys in g_datalist_id_remove_multiple()
If too many keys are requested, they temporary buffer is allocated on the heap. There is no problem in principle, to remove more than 16 keys. Well, the problem is that GData tracks entries in a linear list, so performance will degrade when it grows too much. That is a problem, and users should be careful to not add unreasonably many keys. But it's not the task of g_datalist_id_remove_multiple() to decide what is reasonable. This limitation was present from the beginning, in commit0415bf9412
('Add g_datalist_id_remove_multiple'). It's no longer necessary since commiteada6be364
('gdataset: cleanup g_data_remove_internal()').
This commit is contained in:
parent
48a1d8c695
commit
759ebf3663
@ -736,13 +736,17 @@ g_datalist_id_set_data_full (GData **datalist,
|
|||||||
* g_datalist_id_remove_multiple:
|
* g_datalist_id_remove_multiple:
|
||||||
* @datalist: a datalist
|
* @datalist: a datalist
|
||||||
* @keys: (array length=n_keys): keys to remove
|
* @keys: (array length=n_keys): keys to remove
|
||||||
* @n_keys: length of @keys, must be <= 16
|
* @n_keys: length of @keys.
|
||||||
*
|
*
|
||||||
* Removes multiple keys from a datalist.
|
* Removes multiple keys from a datalist.
|
||||||
*
|
*
|
||||||
* This is more efficient than calling g_datalist_id_remove_data()
|
* This is more efficient than calling g_datalist_id_remove_data()
|
||||||
* multiple times in a row.
|
* multiple times in a row.
|
||||||
*
|
*
|
||||||
|
* Before 2.80, @n_keys had to be not larger than 16. Now it can be larger, but
|
||||||
|
* note that GData does a linear search, so an excessive number of keys will
|
||||||
|
* perform badly.
|
||||||
|
*
|
||||||
* Since: 2.74
|
* Since: 2.74
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
@ -750,8 +754,6 @@ g_datalist_id_remove_multiple (GData **datalist,
|
|||||||
GQuark *keys,
|
GQuark *keys,
|
||||||
gsize n_keys)
|
gsize n_keys)
|
||||||
{
|
{
|
||||||
g_return_if_fail (n_keys <= 16);
|
|
||||||
|
|
||||||
g_data_remove_internal (datalist, keys, n_keys);
|
g_data_remove_internal (datalist, keys, n_keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,7 +347,6 @@ test_datalist_id_remove_multiple_resize (void)
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
/* Mode: remove a list of (random) quarks. */
|
/* Mode: remove a list of (random) quarks. */
|
||||||
n = n % 16;
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
j = (j + PRIME) % N;
|
j = (j + PRIME) % N;
|
||||||
|
Loading…
Reference in New Issue
Block a user