git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] delta micro optimization
@ 2006-02-10 18:42 Nicolas Pitre
  2006-02-10 20:00 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Pitre @ 2006-02-10 18:42 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

My kernel work habit made me look at the generated assembly for the 
delta code, and one obvious albeit small improvement is this patch.

Signed-off-by: Nicolas Pitre <nico@cam.org>

---

diff --git a/delta.h b/delta.h
index 31d1820..a15350d 100644
--- a/delta.h
+++ b/delta.h
@@ -19,14 +19,14 @@ extern void *patch_delta(void *src_buf, 
 static inline unsigned long get_delta_hdr_size(const unsigned char **datap)
 {
 	const unsigned char *data = *datap;
-	unsigned char cmd = *data++;
-	unsigned long size = cmd & ~0x80;
-	int i = 7;
-	while (cmd & 0x80) {
+	unsigned char cmd;
+	unsigned long size = 0;
+	int i = 0;
+	do {
 		cmd = *data++;
 		size |= (cmd & ~0x80) << i;
 		i += 7;
-	}
+	} while (cmd & 0x80);
 	*datap = data;
 	return size;
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-02-10 20:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-10 18:42 [PATCH] delta micro optimization Nicolas Pitre
2006-02-10 20:00 ` Junio C Hamano
2006-02-10 20:38   ` Nicolas Pitre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).