NETSCRIPT: Rework disableLog for efficiency (#1589)

The current implementation was naive; disableLog("ALL") was storing a
key for every function, and iterating over a different object to do it
(when iterating over objects is quite slow).

The common cases of Bitburner (and especially batching, where efficiency
matters most) are either never disabling anything, or disabling "ALL".
This optimizes for these two cases, at the expense of slightly more
complicated code to deal with the less-common edge cases.
This commit is contained in:
David Walker
2024-08-16 19:10:20 -07:00
committed by GitHub
parent 385a9dc11d
commit 34db6e8b26
3 changed files with 121 additions and 19 deletions
+1 -1
View File
@@ -131,7 +131,7 @@ export class WorkerScript {
}
shouldLog(fn: string): boolean {
return this.disableLogs[fn] == null;
return !(this.disableLogs.ALL || this.disableLogs[fn]);
}
log(func: string, txt: () => string): void {