mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 05:16:47 +08:00
syslog: I think this might speed upt the CR-LF scan in syslog_dev_write().
This commit is contained in:
@@ -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.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user