diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2013-01-14 15:52:42 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-01-14 15:52:42 +0100 |
commit | 49d1203b3582f7d637af11a226386a4df186e687 (patch) | |
tree | 8d84867d963ab77b4942130c889b210e2a563221 /runtime/parser.c | |
parent | 47e11d68b2378540a4333d885cb019aad366c46d (diff) | |
download | rsyslog-49d1203b3582f7d637af11a226386a4df186e687.tar.gz rsyslog-49d1203b3582f7d637af11a226386a4df186e687.tar.bz2 rsyslog-49d1203b3582f7d637af11a226386a4df186e687.zip |
optimize: iscntrl() seems to be surprisingly slow
at least so tells the profiler...
Diffstat (limited to 'runtime/parser.c')
-rw-r--r-- | runtime/parser.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/runtime/parser.c b/runtime/parser.c index b40edf4c..777683fb 100644 --- a/runtime/parser.c +++ b/runtime/parser.c @@ -362,11 +362,10 @@ SanitizeMsg(msg_t *pMsg) */ int bNeedSanitize = 0; for(iSrc = 0 ; iSrc < lenMsg ; iSrc++) { - if(iscntrl(pszMsg[iSrc])) { + if(pszMsg[iSrc] < 32) { if(bSpaceLFOnRcv && pszMsg[iSrc] == '\n') pszMsg[iSrc] = ' '; - else - if(pszMsg[iSrc] == '\0' || bEscapeCCOnRcv) { + else if(pszMsg[iSrc] == '\0' || bEscapeCCOnRcv) { bNeedSanitize = 1; if (!bSpaceLFOnRcv) break; @@ -394,7 +393,7 @@ SanitizeMsg(msg_t *pMsg) CHKmalloc(pDst = MALLOC(sizeof(uchar) * (iMaxLine + 1))); iSrc = iDst = 0; while(iSrc < lenMsg && iDst < maxDest - 3) { /* leave some space if last char must be escaped */ - if(iscntrl((int) pszMsg[iSrc]) && (pszMsg[iSrc] != '\t' || bEscapeTab)) { + if((pszMsg[iSrc] < 32) && (pszMsg[iSrc] != '\t' || bEscapeTab)) { /* note: \0 must always be escaped, the rest of the code currently * can not handle it! -- rgerhards, 2009-08-26 */ |