Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BunProcess: dont use for-loop for isSignalName #14285

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/bun.js/bindings/BunProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,16 +683,6 @@ static const NeverDestroyed<String> signalNames[] = {
MAKE_STATIC_STRING_IMPL("SIGSYS"),
};

bool isSignalName(WTF::String input)
{
for (auto i = 0; i < std::size(signalNames); i++) {
if (input == signalNames[i]) {
return true;
}
}
return false;
}

static void loadSignalNumberMap()
{

Expand Down Expand Up @@ -788,6 +778,12 @@ static void loadSignalNumberMap()
});
}

bool isSignalName(WTF::String input)
{
loadSignalNumberMap();
return signalNameToNumberMap->contains(input);
}

#if OS(WINDOWS)
extern "C" uv_signal_t* Bun__UVSignalHandle__init(JSC::JSGlobalObject* lexicalGlobalObject, int signalNumber, void (*callback)(uv_signal_t*, int));
extern "C" uv_signal_t* Bun__UVSignalHandle__close(uv_signal_t*);
Expand Down
Loading