Skip to content

Commit 4c1eb85

Browse files
authored
Cmd: tweak parallelism parse (#1164)
1 parent f6e6141 commit 4c1eb85

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

src/Cmd/Build.cc

+2-5
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,8 @@ buildMain(const CliArgsView args) {
123123
auto [ptr, ec] = std::from_chars(
124124
nextArg.data(), nextArg.data() + nextArg.size(), numThreads
125125
);
126-
if (ec == std::errc()) {
127-
setParallelism(numThreads);
128-
} else {
129-
Bail("invalid number of threads: {}", nextArg);
130-
}
126+
Ensure(ec == std::errc(), "invalid number of threads: {}", nextArg);
127+
setParallelism(numThreads);
131128
} else {
132129
return BUILD_CMD.noSuchArg(arg);
133130
}

src/Cmd/Run.cc

+2-5
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,8 @@ runMain(const CliArgsView args) {
6262
auto [ptr, ec] = std::from_chars(
6363
nextArg.data(), nextArg.data() + nextArg.size(), numThreads
6464
);
65-
if (ec == std::errc()) {
66-
setParallelism(numThreads);
67-
} else {
68-
Bail("invalid number of threads: {}", nextArg);
69-
}
65+
Ensure(ec == std::errc(), "invalid number of threads: {}", nextArg);
66+
setParallelism(numThreads);
7067
} else {
7168
// Unknown argument is the start of the program arguments.
7269
break;

src/Cmd/Tidy.cc

+2-5
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,8 @@ tidyMain(const CliArgsView args) {
6969
auto [ptr, ec] = std::from_chars(
7070
nextArg.data(), nextArg.data() + nextArg.size(), numThreads
7171
);
72-
if (ec == std::errc()) {
73-
setParallelism(numThreads);
74-
} else {
75-
Bail("invalid number of threads: {}", nextArg);
76-
}
72+
Ensure(ec == std::errc(), "invalid number of threads: {}", nextArg);
73+
setParallelism(numThreads);
7774
} else {
7875
return TIDY_CMD.noSuchArg(arg);
7976
}

0 commit comments

Comments
 (0)