[gjs/march-maintenance: 9/11] object: Readability improvement in is_gobject_property_name()



commit e4740df98ad8da882bdc97b8bbc2e5fed524458b
Author: Philip Chimento <philip chimento gmail com>
Date:   Wed Mar 11 22:51:55 2020 -0700

    object: Readability improvement in is_gobject_property_name()
    
    It seems there's no reason not to return early here.

 gi/object.cpp | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index 2259886e..daf02f45 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -739,29 +739,22 @@ is_gobject_property_name(GIObjectInfo *info,
     int n_props = g_object_info_get_n_properties(info);
     int n_ifaces = g_object_info_get_n_interfaces(info);
     int ix;
-    GjsAutoPropertyInfo prop_info;
 
     GjsAutoChar canonical_name = gjs_hyphen_from_camel(name);
     canonicalize_key(canonical_name);
 
     for (ix = 0; ix < n_props; ix++) {
-        prop_info = g_object_info_get_property(info, ix);
+        GjsAutoPropertyInfo prop_info = g_object_info_get_property(info, ix);
         if (strcmp(canonical_name, prop_info.name()) == 0)
-            break;
-        prop_info.reset();
+            return true;
     }
 
-    if (!prop_info) {
-        for (ix = 0; ix < n_ifaces; ix++) {
-            GjsAutoInterfaceInfo iface_info =
-                g_object_info_get_interface(info, ix);
-            if (is_ginterface_property_name(iface_info, canonical_name))
-                return true;
-        }
-        return false;
+    for (ix = 0; ix < n_ifaces; ix++) {
+        GjsAutoInterfaceInfo iface_info = g_object_info_get_interface(info, ix);
+        if (is_ginterface_property_name(iface_info, canonical_name))
+            return true;
     }
-
-    return true;
+    return false;
 }
 
 // Override of GIWrapperBase::id_is_never_lazy()


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