Revision: 14355 Author: adrian.chadd Date: Wed Nov 4 06:13:00 2009 Log: Change storeKeyText() to generate its own hex store key string rather than using printf().
This actually causes a non-trivial amount of user CPU to be used wherever store key logging is done - eg, via store.log. http://code.google.com/p/lusca-cache/source/detail?r=14355 Modified: /branches/LUSCA_HEAD/src/store_key_md5.c ======================================= --- /branches/LUSCA_HEAD/src/store_key_md5.c Mon Oct 26 23:58:33 2009 +++ /branches/LUSCA_HEAD/src/store_key_md5.c Wed Nov 4 06:13:00 2009 @@ -38,15 +38,23 @@ static cache_key null_key[SQUID_MD5_DIGEST_LENGTH]; static MemPool * pool_md5_key = NULL; +/* XXX this should be uhm, a library function! [ahc] */ +static char tohex[] = { '0','1','2','3','4','5','6','7','8','9', 'A', 'B', 'C', 'D', 'E', 'F' }; + const char * storeKeyText(const unsigned char *key) { - static MemBuf mb = MemBufNULL; + static char buf[SQUID_MD5_DIGEST_LENGTH*2+1]; + char *b = buf; int i; - memBufReset(&mb); - for (i = 0; i < SQUID_MD5_DIGEST_LENGTH; i++) - memBufPrintf(&mb, "%02X", *(key + i)); - return mb.buf; + + for (i = 0; i < SQUID_MD5_DIGEST_LENGTH; i++) { + *(b++) = tohex[(key[i] >> 4) & 0x0f]; + *(b++) = tohex[key[i] & 0x0f]; + } + *b = '\0'; + + return buf; } const cache_key * --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "lusca-commit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/lusca-commit?hl=en -~----------~----~----~----~------~----~------~--~---
