mirror of
https://github.com/espressif/openthread.git
synced 2026-08-11 21:27:46 +00:00
[string] introduce StringWriter class (#6564)
This commit moves methods of String out of the header file to save code size. Since most use cases of String writers ignores errors, this commit changes the return of writers to the Writer object itself for chained writes.
This commit is contained in:
@@ -212,6 +212,7 @@ void Notifier::LogEvents(Events aEvents) const
|
||||
bool addSpace = false;
|
||||
bool didLog = false;
|
||||
String<kFlagsStringBufferSize> string;
|
||||
StringWriter writer(string);
|
||||
|
||||
for (uint8_t bit = 0; bit < sizeof(Events::Flags) * CHAR_BIT; bit++)
|
||||
{
|
||||
@@ -219,16 +220,16 @@ void Notifier::LogEvents(Events aEvents) const
|
||||
|
||||
if (flags & (1 << bit))
|
||||
{
|
||||
if (string.GetLength() >= kFlagsStringLineLimit)
|
||||
if (writer.GetLength() >= kFlagsStringLineLimit)
|
||||
{
|
||||
otLogInfoCore("Notifier: StateChanged (0x%08x) %s%s ...", aEvents.GetAsFlags(), didLog ? "... " : "[",
|
||||
string.AsCString());
|
||||
string.Clear();
|
||||
writer.Clear();
|
||||
didLog = true;
|
||||
addSpace = false;
|
||||
}
|
||||
|
||||
IgnoreError(string.Append("%s%s", addSpace ? " " : "", EventToString(static_cast<Event>(1 << bit))));
|
||||
writer.Append("%s%s", addSpace ? " " : "", EventToString(static_cast<Event>(1 << bit)));
|
||||
addSpace = true;
|
||||
|
||||
flags ^= (1 << bit);
|
||||
|
||||
Reference in New Issue
Block a user