From 6ba19e3b5bdc0fb68fe2407d4d9ab80105df5d7e Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Thu, 17 Jul 2003 16:17:04 +0000 Subject: Speed up ap_md5digest() a little. * util_md5.c (ap_md5digest): Use a larger buffer; ensure size is a multiple of 64 to prevent buffering in MD5 code. Remove redundant 'length' variable. Reset read size in case of short reads. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@100672 13f79535-47bb-0310-9956-ffa450edef68 --- server/util_md5.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'server/util_md5.c') diff --git a/server/util_md5.c b/server/util_md5.c index 5d8068b23b..6ec4571e1c 100644 --- a/server/util_md5.c +++ b/server/util_md5.c @@ -198,16 +198,15 @@ AP_DECLARE(char *) ap_md5contextTo64(apr_pool_t *a, apr_md5_ctx_t *context) AP_DECLARE(char *) ap_md5digest(apr_pool_t *p, apr_file_t *infile) { apr_md5_ctx_t context; - unsigned char buf[1000]; - long length = 0; + unsigned char buf[4096]; /* keep this a multiple of 64 */ apr_size_t nbytes; apr_off_t offset = 0L; apr_md5_init(&context); nbytes = sizeof(buf); while (apr_file_read(infile, buf, &nbytes) == APR_SUCCESS) { - length += nbytes; apr_md5_update(&context, buf, nbytes); + nbytes = sizeof(buf); } apr_file_seek(infile, APR_SET, &offset); return ap_md5contextTo64(p, &context); -- cgit v1.2.3