[pango/test-coverage: 2/20] markup: Save a few lines




commit 7127ec2274a650758093d92b742b9bb0a5a6eed7
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 26 14:49:09 2021 -0400

    markup: Save a few lines
    
    pango_markup_parser_new_internal can't really fail.

 pango/pango-markup.c | 24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)
---
diff --git a/pango/pango-markup.c b/pango/pango-markup.c
index 258ca717..9721595d 100644
--- a/pango/pango-markup.c
+++ b/pango/pango-markup.c
@@ -584,17 +584,10 @@ pango_markup_parser_new_internal (char       accel_marker,
                                        0, md,
                                         (GDestroyNotify)destroy_markup_data);
 
-  if (!g_markup_parse_context_parse (context,
-                                     "<markup>",
-                                     -1,
-                                     error))
-    goto error;
+  if (!g_markup_parse_context_parse (context, "<markup>", -1, error))
+    g_clear_pointer (&context, g_markup_parse_context_free);
 
   return context;
-
- error:
-  g_markup_parse_context_free (context);
-  return NULL;
 }
 
 /**
@@ -654,8 +647,6 @@ pango_parse_markup (const char                 *markup_text,
   context = pango_markup_parser_new_internal (accel_marker,
                                               error,
                                               (attr_list != NULL));
-  if (context == NULL)
-    goto out;
 
   if (!g_markup_parse_context_parse (context,
                                      markup_text,
@@ -711,16 +702,9 @@ pango_parse_markup (const char                 *markup_text,
  * Since: 1.31.0
  **/
 GMarkupParseContext *
-pango_markup_parser_new (gunichar               accel_marker)
+pango_markup_parser_new (gunichar accel_marker)
 {
-  GError *error = NULL;
-  GMarkupParseContext *context;
-  context = pango_markup_parser_new_internal (accel_marker, &error, TRUE);
-
-  if (context == NULL)
-    g_critical ("Had error when making markup parser: %s\n", error->message);
-
-  return context;
+  return pango_markup_parser_new_internal (accel_marker, NULL, TRUE);
 }
 
 /**


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