syslog: I think this might speed upt the CR-LF scan in syslog_dev_write().

This commit is contained in:
Gregory Nutt
2017-05-12 08:50:56 -06:00
parent c84a3e3519
commit fc7c3f5328
+9 -8
View File
@@ -518,24 +518,24 @@ ssize_t syslog_dev_write(FAR const char *buffer, size_t buflen)
remaining > 0; remaining > 0;
endptr++, remaining--) endptr++, remaining--)
{ {
bool crlf = false; /* Check for carriage return or line feed */
/* Check for a CR-LF sequence */ if (*endptr == '\r' || *endptr == '\n')
{
/* Check for pre-formatted CR-LF sequence */
if (remaining > 1 && if (remaining > 1 &&
((endptr[0] == '\r' && endptr[1] == '\n') || ((endptr[0] == '\r' && endptr[1] == '\n') ||
(endptr[0] == '\n' && endptr[1] == '\r'))) (endptr[0] == '\n' && endptr[1] == '\r')))
{ {
/* Just skip over pre-formatted CR-LF or LF-CR sequence */
endptr++; endptr++;
remaining--; remaining--;
crlf = true;
} }
else
/* Special case carriage return and line feed */
if (!crlf && (*endptr == '\r' || *endptr == '\n'))
{ {
/* Write everything up to this point, ignore the special /* Write everything up to the position of the special
* character. * character.
* *
* - buffer points to next byte to output. * - buffer points to next byte to output.
@@ -573,6 +573,7 @@ ssize_t syslog_dev_write(FAR const char *buffer, size_t buflen)
buffer += writelen; /* Points past the special character */ buffer += writelen; /* Points past the special character */
} }
} }
}
/* Write any unterminated data at the end of the buffer. /* Write any unterminated data at the end of the buffer.
* *