libos: Make File::read_all() read chunked blocks instead of one character at a time
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This results in a speedup of 0.23s -> 0.13s for Base64 encoding of /bin/ls.
This commit is contained in:
parent
3283991ec6
commit
85896214ba
@ -154,18 +154,18 @@ namespace os
|
||||
|
||||
Result<Buffer> File::read_all()
|
||||
{
|
||||
Vector<u8> data;
|
||||
Buffer data;
|
||||
|
||||
u8 buf[2048];
|
||||
|
||||
while (true)
|
||||
{
|
||||
int c = TRY(getchar());
|
||||
if (c == -1) break;
|
||||
TRY(data.try_append((u8)c));
|
||||
usize nread = TRY(raw_read(buf, sizeof(buf)));
|
||||
TRY(data.append_data(buf, nread));
|
||||
if (nread < sizeof(buf)) break;
|
||||
}
|
||||
|
||||
Buffer buf;
|
||||
TRY(buf.append_data(data.data(), data.size()));
|
||||
return buf;
|
||||
return data;
|
||||
}
|
||||
|
||||
Result<void> File::read(Buffer& buf, usize size)
|
||||
|
Loading…
Reference in New Issue
Block a user