[PATCH] blkparse_fmt: use memcmp() it is (usually) faster
authorJens Axboe <axboe@suse.de>
Fri, 7 Oct 2005 09:12:58 +0000 (11:12 +0200)
committerJens Axboe <axboe@suse.de>
Fri, 7 Oct 2005 09:12:58 +0000 (11:12 +0200)
At least it has better worst case performance.

blkparse_fmt.c

index 8031a8e661bba91bdabec497a4ba24dace9fe594..34b920b2256de9caf6250444f08fc10c780edcf7 100644 (file)
@@ -79,14 +79,11 @@ static inline void fill_rwbs(char *rwbs, struct blk_io_trace *t)
        rwbs[i] = '\0';
 }
 
-static int pdu_rest_is_zero(unsigned char *pdu, int len)
+static inline int pdu_rest_is_zero(unsigned char *pdu, int len)
 {
-       int i = 0;
-
-       while (!pdu[i] && i < len)
-               i++;
+       static char zero[4096];
 
-       return i == len;
+       return !memcmp(pdu, zero, len);
 }
 
 static char *dump_pdu(unsigned char *pdu_buf, int pdu_len)