diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-10-11 18:19:25 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-10-11 18:19:25 +0000 |
commit | db1aadaa5e895731a3cbd4b8684a16e35515418a (patch) | |
tree | 822a0ddcfefcb0eef6876c1808ffcae803b5fdf9 | |
parent | cf4d8a3bdcc0f89e83d0fefd3b167e8dfdd97992 (diff) | |
parent | 6e341750dfbcf752e23f2eadb5072606e1a016d8 (diff) | |
download | glib-db1aadaa5e895731a3cbd4b8684a16e35515418a.tar.gz |
Merge branch 'str-equal-only' into 'main'
g_str_equal: Provide macro for optimization
Closes #2775
See merge request GNOME/glib!2940
-rw-r--r-- | glib/ghash.c | 4 | ||||
-rw-r--r-- | glib/ghash.h | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/glib/ghash.c b/glib/ghash.c index 6c9514207..808ec628a 100644 --- a/glib/ghash.c +++ b/glib/ghash.c @@ -2323,8 +2323,8 @@ g_hash_table_get_values (GHashTable *hash_table) * Returns: %TRUE if the two keys match */ gboolean -g_str_equal (gconstpointer v1, - gconstpointer v2) +(g_str_equal) (gconstpointer v1, + gconstpointer v2) { const gchar *string1 = v1; const gchar *string2 = v2; diff --git a/glib/ghash.h b/glib/ghash.h index cbd2f98bf..8e7f4a0d1 100644 --- a/glib/ghash.h +++ b/glib/ghash.h @@ -160,6 +160,10 @@ void g_hash_table_unref (GHashTable *hash_table); GLIB_AVAILABLE_IN_ALL gboolean g_str_equal (gconstpointer v1, gconstpointer v2); + +/* Macro for optimization in the case it is not used as callback function */ +#define g_str_equal(v1, v2) (strcmp ((v1), (v2)) == 0) + GLIB_AVAILABLE_IN_ALL guint g_str_hash (gconstpointer v); |