[glib/gobject-speedups: 21/23] param: Avoid strcmps




commit 4b468b2a889916cc2cfe57dd50968dedf1f66bf8
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.

 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]