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

CLI: Slightly reduce memory allocations #2843

Merged
merged 1 commit into from
Feb 8, 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
5 changes: 2 additions & 3 deletions source/dub/commandline.d
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
*/
string[] commandNames()
{
return commandGroups.map!(g => g.commands.map!(c => c.name).array).join;
return commandGroups.map!(g => g.commands).joiner.map!(c => c.name).array;
}

/** Parses the general options and sets up the log level
Expand Down Expand Up @@ -405,7 +405,6 @@
}

auto handler = CommandLineHandler(getCommands());
auto commandNames = handler.commandNames();

// Special syntaxes need to be handled before regular argument parsing
if (args.length >= 2)
Expand Down Expand Up @@ -435,7 +434,7 @@
// We have to assume it isn't, and to reduce the risk of false positive
// we only consider the case where the file name is the first argument,
// as the shell invocation cannot be controlled.
else if (!commandNames.canFind(args[1]) && !args[1].startsWith("-")) {
else if (handler.getCommand(args[1]) is null && !args[1].startsWith("-")) {

Check warning on line 437 in source/dub/commandline.d

View check run for this annotation

Codecov / codecov/patch

source/dub/commandline.d#L437

Added line #L437 was not covered by tests
if (exists(args[1])) {
auto path = getTempFile("app", ".d");
copy(args[1], path.toNativeString());
Expand Down
Loading