mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 19:05:06 +00:00
Kernel/DevPtsFS: Avoid String allocation during directory traversal
Use a StringBuilder to generate a temporary string buffer with the slave PTY names. (This works because StringBuilder has 128 bytes of inline stack capacity before it does any heap allocations.)
This commit is contained in:
parent
0de8c95d49
commit
3a2d888913
1 changed files with 3 additions and 3 deletions
|
@ -118,9 +118,9 @@ KResult DevPtsFSInode::traverse_as_directory(Function<bool(FileSystem::Directory
|
||||||
|
|
||||||
SlavePTY::all_instances().with([&](auto& list) {
|
SlavePTY::all_instances().with([&](auto& list) {
|
||||||
for (SlavePTY& slave_pty : list) {
|
for (SlavePTY& slave_pty : list) {
|
||||||
String name = String::number(slave_pty.index());
|
StringBuilder builder;
|
||||||
InodeIdentifier identifier = { fsid(), pty_index_to_inode_index(slave_pty.index()) };
|
builder.appendff("{}", slave_pty.index());
|
||||||
callback({ name, identifier, 0 });
|
callback({ builder.string_view(), { fsid(), pty_index_to_inode_index(slave_pty.index()) }, 0 });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue