[gnome-software] odrs: Use immutable JSON parsers



commit b4856f5c6d3f663062be4a8c57d5dc3cfd076e03
Author: Philip Withnall <withnall endlessm com>
Date:   Tue Jun 2 14:31:21 2020 +0100

    odrs: Use immutable JSON parsers
    
    This doesn’t affect parsing time significantly (it seems stable at
    125–130ms), but would improve performance were the resulting `JsonNode`s
    to be hashed or passed around extensively in future.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 plugins/odrs/gs-plugin-odrs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/plugins/odrs/gs-plugin-odrs.c b/plugins/odrs/gs-plugin-odrs.c
index 5bb70626..161ceb89 100644
--- a/plugins/odrs/gs-plugin-odrs.c
+++ b/plugins/odrs/gs-plugin-odrs.c
@@ -193,7 +193,7 @@ gs_plugin_odrs_load_ratings (GsPlugin *plugin, const gchar *fn, GError **error)
        g_autoptr(GMutexLocker) locker = NULL;
 
        /* parse the data and find the success */
-       json_parser = json_parser_new ();
+       json_parser = json_parser_new_immutable ();
        if (!json_parser_load_from_file (json_parser, fn, error)) {
                gs_utils_error_convert_json_glib (error);
                return FALSE;
@@ -406,7 +406,7 @@ gs_plugin_odrs_parse_reviews (GsPlugin *plugin,
        }
 
        /* parse the data and find the array or ratings */
-       json_parser = json_parser_new ();
+       json_parser = json_parser_new_immutable ();
        if (!json_parser_load_from_data (json_parser, data, data_len, error)) {
                gs_utils_error_convert_json_glib (error);
                return NULL;
@@ -492,7 +492,7 @@ gs_plugin_odrs_parse_success (const gchar *data, gssize data_len, GError **error
        }
 
        /* parse the data and find the success */
-       json_parser = json_parser_new ();
+       json_parser = json_parser_new_immutable ();
        if (!json_parser_load_from_data (json_parser, data, data_len, error)) {
                gs_utils_error_convert_json_glib (error);
                return FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]