[glib/param-speedups: 1/3] param: Avoid strcmps




commit 91dafa85fc27a75b7bc304eff3e1f1eb9b615c9a
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu May 19 18:45:58 2022 -0400

    param: Avoid strcmps
    
    Most of the time, we are dealing with static strings,
    and we can compare them directly and avoid the strcmp.
    
    Note that triggering this optimization requires
    properties to be marked as G_PARAM_STATIC_NAME.

 gobject/gparam.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/gobject/gparam.c b/gobject/gparam.c
index e9d9eacb07..bd9bd447fd 100644
--- a/gobject/gparam.c
+++ b/gobject/gparam.c
@@ -923,7 +923,8 @@ param_spec_pool_equals (gconstpointer key_spec_1,
   const GParamSpec *key2 = key_spec_2;
 
   return (key1->owner_type == key2->owner_type &&
-         strcmp (key1->name, key2->name) == 0);
+          (key1->name == key2->name ||
+          strcmp (key1->name, key2->name) == 0));
 }
 
 /**


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