mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:37:34 +00:00
Add a simple StringBuilder::appendf() and use it for ProcFS.
Okay, now ProcFS doesn't crash due to the crappy buffer size estimates not really working out. This thing has dogshit performance and I will fix that separately.
This commit is contained in:
parent
dad58db757
commit
074edffc44
4 changed files with 83 additions and 116 deletions
|
@ -1,4 +1,6 @@
|
|||
#include "StringBuilder.h"
|
||||
#include <LibC/stdarg.h>
|
||||
#include "printf.cpp"
|
||||
|
||||
namespace AK {
|
||||
|
||||
|
@ -17,6 +19,16 @@ void StringBuilder::append(char ch)
|
|||
m_strings.append(StringImpl::create(&ch, 1));
|
||||
}
|
||||
|
||||
void StringBuilder::appendf(const char* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
printfInternal([this] (char*&, char ch) {
|
||||
append(ch);
|
||||
}, nullptr, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
String StringBuilder::build()
|
||||
{
|
||||
auto strings = move(m_strings);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue