[giggle] [libgiggle] Avoid type checking in heavily used methods.



commit 0a9349dbcf6dbb365cf647a6f6338c4408c40973
Author: Edward Hervey <bilboed bilboed com>
Date:   Thu Apr 1 10:00:17 2010 +0200

    [libgiggle] Avoid type checking in heavily used methods.
    
    Those properties are accessed way way way too often to allow ourselves
    to do heavy type checking.
    
    It's risky... but there's a substantial speedup
    
    https://bugzilla.gnome.org/show_bug.cgi?id=614546

 libgiggle/giggle-ref.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/libgiggle/giggle-ref.c b/libgiggle/giggle-ref.c
index d264dea..a97ac35 100644
--- a/libgiggle/giggle-ref.c
+++ b/libgiggle/giggle-ref.c
@@ -179,15 +179,17 @@ giggle_ref_new (const gchar *name)
 G_CONST_RETURN gchar *
 giggle_ref_get_name (GiggleRef *ref)
 {
-	g_return_val_if_fail (GIGGLE_IS_REF (ref), NULL);
+	if (G_LIKELY (ref))
+		return ref->priv->name;
 
-	return ref->priv->name;
+	return NULL;
 }
 
 G_CONST_RETURN gchar *
 giggle_ref_get_sha (GiggleRef *ref)
 {
-	g_return_val_if_fail (GIGGLE_IS_REF (ref), NULL);
+	if (G_LIKELY (ref))
+		return ref->priv->sha;
 
-	return ref->priv->sha;
+	return NULL;
 }



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