gdataset: add code comment to g_datalist_get_data()

It's not obvious why we wouldn't use g_quark_try_string(). Add a code
comment that this is intentional and a reference for how to find out
more.

Also, fix typo in another code comment.
This commit is contained in:
Thomas Haller 2024-02-05 15:45:29 +01:00
parent bcc22d48b0
commit 10d4351ec9

View File

@ -211,7 +211,7 @@ datalist_remove (GData *data, guint32 idx)
/* g_data_remove_internal() relies on the fact, that this function removes
* the entry similar to g_array_remove_index_fast(). That is, the entries up
* to @idx are left unchanged, and the last entry at moved to position @idx.
* to @idx are left unchanged, and the last entry is moved to position @idx.
* */
data->len--;
@ -1244,6 +1244,12 @@ g_datalist_get_data (GData **datalist,
data_end = data + d->len;
while (data < data_end)
{
/* Here we intentionally compare by strings, instead of calling
* g_quark_try_string() first.
*
* See commit 1cceda49b60b ('Make g_datalist_get_data not look up the
* quark').
*/
if (g_strcmp0 (g_quark_to_string (data->key), key) == 0)
{
res = data->data;