Bug 622590 - dict ordering must match for g_variant_equal()
dict ordering must match for g_variant_equal()
Status: NEW
Product: glib
Classification: Platform
Component: gvariant
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Allison Lortie (desrt) (extended vacation)
gtkdev
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2010-06-24 12:09 UTC by Danielle Madeley
Modified: 2010-06-26 14:36 UTC (History)
2 users (show)

See Also:
GNOME target: ---
GNOME version: ---


Attachments
first pass at a patch (2.43 KB, patch)
2010-06-25 02:06 UTC, Danielle Madeley
none Details | Diff | Review
Alternative implementation for a g_variant_equivalent (2.43 KB, text/plain)
2010-06-25 04:15 UTC, Danielle Madeley
  Details

Description Danielle Madeley 2010-06-24 12:09:48 UTC
The ordering of two dictionaries (e.g. a{os}) must be identical for g_variant_equal() to return TRUE.
Comment 1 Danielle Madeley 2010-06-25 02:06:05 UTC
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.
Comment 2 Danielle Madeley 2010-06-25 04:15:45 UTC
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.
Comment 3 Allison Lortie (desrt) (extended vacation) 2010-06-25 12:06:18 UTC
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.
Comment 4 Aaron Bockover 2010-06-26 01:09:52 UTC
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.
Comment 5 Allison Lortie (desrt) (extended vacation) 2010-06-26 14:36:58 UTC
dictionaries in GVariant behave exactly as they do in DBus.

Note You need to log in before you can comment on or make changes to this bug.