summaryrefslogtreecommitdiffstats
path: root/runtime/parser.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2013-01-14 16:35:38 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2013-01-14 16:35:38 +0100
commitbeed1bda6969b70b608ff9e606f52ac6d41cc8c1 (patch)
tree0272fd26470f4dd4244537c3425cb67a10d58df9 /runtime/parser.c
parent227d8faed2b70a4bf3bd9bb1d6078e5fdf845d3c (diff)
downloadrsyslog-beed1bda6969b70b608ff9e606f52ac6d41cc8c1.tar.gz
rsyslog-beed1bda6969b70b608ff9e606f52ac6d41cc8c1.tar.bz2
rsyslog-beed1bda6969b70b608ff9e606f52ac6d41cc8c1.zip
optimize: save inspection of already-inspected data
this is just a small improvement, but let's get the benefit ;)
Diffstat (limited to 'runtime/parser.c')
-rw-r--r--runtime/parser.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/runtime/parser.c b/runtime/parser.c
index 777683fb..74b28f4c 100644
--- a/runtime/parser.c
+++ b/runtime/parser.c
@@ -382,7 +382,9 @@ SanitizeMsg(msg_t *pMsg)
FINALIZE;
}
- /* now copy over the message and sanitize it */
+ /* now copy over the message and sanitize it. Note that up to iSrc-1 there was
+ * obviously no need to sanitize, so we can go over that quickly...
+ */
iMaxLine = glbl.GetMaxLine();
maxDest = lenMsg * 4; /* message can grow at most four-fold */
if(maxDest > iMaxLine)
@@ -391,7 +393,11 @@ SanitizeMsg(msg_t *pMsg)
pDst = szSanBuf;
else
CHKmalloc(pDst = MALLOC(sizeof(uchar) * (iMaxLine + 1)));
- iSrc = iDst = 0;
+ if(iSrc > 0) {
+ iSrc--; /* go back to where everything is OK */
+ memcpy(pDst, pszMsg, iSrc); /* fast copy known good */
+ }
+ iDst = iSrc;
while(iSrc < lenMsg && iDst < maxDest - 3) { /* leave some space if last char must be escaped */
if((pszMsg[iSrc] < 32) && (pszMsg[iSrc] != '\t' || bEscapeTab)) {
/* note: \0 must always be escaped, the rest of the code currently