From 6ddbc94c9888e5ddcd1cbb15845d2f1b5524b3ed Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 1 Mar 2016 15:01:07 +0000 Subject: core: Add JSON node, object, array hashes Now that these objects can be marked as immutable, it is possible to calculate and cache hash values for each of them. This allows efficient hash-based deduplication of large numbers of JSON nodes, as needed by Walbottle for JSON test vector generation. To complement the new hash functions, each of JsonNode, JsonValue, JsonObject and JsonArray also now have an equal() comparison method. This compares them structurally and recursively, using the definition of equality from the JSON Schema specification, which seems as good as any other. http://json-schema.org/latest/json-schema-core.html#anchor9 https://bugzilla.gnome.org/show_bug.cgi?id=756121 Signed-off-by: Emmanuele Bassi --- json-glib/json-parser.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'json-glib/json-parser.c') diff --git a/json-glib/json-parser.c b/json-glib/json-parser.c index a7b1c32..a48e9b2 100644 --- a/json-glib/json-parser.c +++ b/json-glib/json-parser.c @@ -610,9 +610,7 @@ json_parse_array (JsonParser *parser, array_done: json_scanner_get_next_token (scanner); - /* We can guarantee that all the array elements are immutable, so we - * can skip the formal loop over them to seal them again. */ - array->immutable = TRUE; + json_array_seal (array); json_node_take_array (priv->current_node, array); if (priv->immutable) @@ -793,9 +791,7 @@ json_parse_object (JsonParser *parser, json_scanner_get_next_token (scanner); - /* We can guarantee that all the object members are immutable, so we - * can skip the formal loop over them to seal them again. */ - object->immutable = TRUE; + json_object_seal (object); json_node_take_object (priv->current_node, object); if (priv->immutable) -- cgit v1.2.1