1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

Reduce kmalloc() traffic in directory iteration.

Pass the file name in a stack-allocated buffer instead of using an AK::String
when iterating directories. This dramatically reduces the amount of cycles
spent traversing the filesystem.
This commit is contained in:
Andreas Kling 2018-11-13 00:17:30 +01:00
parent 5e8e554f94
commit 19b9401487
10 changed files with 60 additions and 40 deletions

View file

@ -16,12 +16,13 @@ struct GlobalState {
char ttyname[32];
char hostname[32];
pid_t sid;
uid_t uid;
};
static GlobalState* g;
static void prompt()
{
if (getuid() == 0)
if (g->uid == 0)
printf("# ");
else
printf("\033[31;1m%s\033[0m@\033[37;1m%s\033[0m:\033[32;1m%s\033[0m$> ", g->username.characters(), g->hostname, g->cwd.characters());
@ -350,6 +351,7 @@ static void greeting()
int main(int, char**)
{
g = new GlobalState;
g->uid = getuid();
g->sid = setsid();
tcsetpgrp(0, getpgrp());