GNOME Bugzilla – Bug 622590
dict ordering must match for g_variant_equal()
Last modified: 2018-05-24 12:23:48 UTC
The ordering of two dictionaries (e.g. a{os}) must be identical for g_variant_equal() to return TRUE.
Created attachment 164574 [details] [review] first pass at a patch This is a first pass at a patch to make dict ordering unimportant. It has the limitation where it currently only works for a{?*} and not dictionaries inside other containers, e.g. aa{?*}. The way to resolve this would be to make g_variant_equal recurse for container types, but this will make g_variant_equal slower. Since the primary use for g_variant_equal() seems to be its use in hash tables, and you already can't hash a non-simple key, perhaps the correct solution is to add a more semantically correct version of g_variant_equal() for use in other places.
Created attachment 164579 [details] Alternative implementation for a g_variant_equivalent Here is an implementation of a g_variant_equivalent that I wrote for my test cases.
We chatted on IRC last night -- there is no chance that either of these pieces of code will make it into glib itself. What we need instead is a comprehensive review of what a dictionary means in GVariant. I'm leaving this bug open pending that review and so that people are more likely to find the code in comment 2, if they need it.
If a dictionary in GVariant doesn't act like a dictionary in any other implementation, I would consider renaming it in GVariant to avoid any confusion.
dictionaries in GVariant behave exactly as they do in DBus.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/314.