Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r196 - in trunk: . fsvs/src

fsvs
Discussion topic

Back to topic list

svn commit: r196 - in trunk: . fsvs/src

Author pmarek
Full name P.Marek
Date 2006-02-21 23:21:45 PST
Message Author: pmarek
Date: Tue Feb 21 23:21:44 2006
New Revision: 196

Modified:
   trunk/ (props changed)
   trunk/fsvs/src/checksum.c
Log:
small optimization for md5-to-hex



Modified: trunk/fsvs/src/checksum.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/che​cksum.c?view=diff​&rev=196&p1=tru​nk/fsvs/src/checksum​.c&r1=195&p2​=trunk/fsvs/src/chec​ksum.c&r2=196
====================​====================​====================​==================
--- trunk/fsvs/src/checksum.c (original)
+++ trunk/fsvs/src/checksum.c Tue Feb 21 23:21:44 2006
@@ -82,10 +82,34 @@
     if (last >= sizeof(stg)/sizeof(stg[0])) last=0;
     cur=stg[last];
 
+ /* According to callgrind is this one of the most cpu-intensive
+ * places in *this* program (not counting libraries).
+ * Of course, it vanishes against apr_file_read and others ...
+ * But optimizing makes fun, and acta est fabula...
+ *
+ * If I read kcachegrind correctly, that shaved 1% runtime off on
+ * a simple "fsvs up".
+ *
+ * If there were only something like #while .... */
+ // slightly better
+ sprintf(cur,
+ "%02x" "%02x" "%02x" "%02x"
+ "%02x" "%02x" "%02x" "%02x"
+ "%02x" "%02x" "%02x" "%02x"
+ "%02x" "%02x" "%02x" "%02x"
+ ,
+ md5[4*0+0], md5[4*0+1], md5[4*0+2], md5[4*0+3],
+ md5[4*1+0], md5[4*1+1], md5[4*1+2], md5[4*1+3],
+ md5[4*2+0], md5[4*2+1], md5[4*2+2], md5[4*2+3],
+ md5[4*3+0], md5[4*3+1], md5[4*3+2], md5[4*3+3]
+ );
+#if 0
+ // Simple, slow variant
     for (i=0; i<APR_MD5_DIGESTSIZE; i++)
     {
         sprintf(cur+i*2, "%02x", md5[i]);
     }
+#endif
 
     return cur;
 }

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r196 - in trunk: . fsvs/src pmarek P.Marek 2006-02-21 23:21:45 PST
Messages per page: