Skip to content

Commit

Permalink
move maxThreads outside of loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Brignull committed Aug 17, 2020
1 parent aaeb975 commit 5eb3736
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/util.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,12 @@ export function getMemoryFlag(): string {
export function getThreadsFlag(): string {
let numThreads: number;
const numThreadsString = core.getInput("threads");
const maxThreads = os.cpus().length;
if (numThreadsString) {
numThreads = Number(numThreadsString);
if (Number.isNaN(numThreads)) {
throw new Error(`Invalid threads setting "${numThreadsString}", specified.`);
}
const maxThreads = os.cpus().length;
if (numThreads > maxThreads) {
core.info(`Clamping desired number of threads (${numThreads}) to max available (${maxThreads}).`);
numThreads = maxThreads;
Expand All @@ -402,7 +402,7 @@ export function getThreadsFlag(): string {
}
} else {
// Default to using all threads
numThreads = os.cpus().length;
numThreads = maxThreads;
}
return `--threads=${numThreads}`;
}
Expand Down

0 comments on commit 5eb3736

Please sign in to comment.