[master] 89bf18a Minor cleanups in varnishtop

Tollef Fog Heen tfheen at varnish-cache.org
Mon Nov 19 11:05:11 CET 2012


commit 89bf18a82bccd94470c4d3c561ec0c9e7b02e92e
Author: Tollef Fog Heen <tfheen at varnish-software.com>
Date:   Mon Nov 19 11:04:34 2012 +0100

    Minor cleanups in varnishtop
    
    Some minor cleanups, no functional changes.  Thanks to Federico
    Schwindt for pointing this out.

diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c
index 7cf1568..e217f28 100644
--- a/bin/varnishtop/varnishtop.c
+++ b/bin/varnishtop/varnishtop.c
@@ -66,7 +66,8 @@ struct top {
 	double			count;
 };
 
-static int top_cmp(const struct top *tp, const struct top *tp2);
+static int
+top_cmp(const struct top *tp, const struct top *tp2);
 
 static VRB_HEAD(top_tree, top) top_tree_head = VRB_INITIALIZER(&top_tree_head);
 VRB_PROTOTYPE(top_tree, top, entry, top_cmp);
@@ -83,22 +84,18 @@ static unsigned maxfieldlen = 0;
 
 VRB_GENERATE(top_tree, top, entry, top_cmp);
 
-static int top_cmp(const struct top *tp, const struct top *tp2)
+static int
+top_cmp(const struct top *tp, const struct top *tp2)
 {
 	if (tp->count == tp2->count || tp->count == 0.0) {
-		if (tp->hash == tp2->hash) {
-			if (tp->tag == tp2->tag) {
-				if (tp->clen == tp2->clen) {
-					return (memcmp(tp->rec_data, tp2->rec_data, tp->clen));
-				} else {
-					return (tp->clen - tp2->clen);
-				}
-			} else {
-				return (tp->tag - tp2->tag);
-			}
-		} else {
+		if (tp->hash != tp2->hash)
 			return (tp->hash - tp2->hash);
-		}
+		if (tp->tag != tp2->tag)
+			return (tp->tag - tp2->tag);
+		if (tp->clen != tp2->clen)
+			return (tp->clen - tp2->clen);
+		else
+			return (memcmp(tp->rec_data, tp2->rec_data, tp->clen));
 	} else {
 		if (tp->count > tp2->count)
 			return -1;



More information about the varnish-commit mailing list