mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-20 16:22:56 +02:00
MISC: Improve several things relating to PID lookups (#1594)
findRunningScriptByPid needlessly took a "server" argument. This caused there to be a "getRunningScriptByPid" version that did *not*, and it was looping through all servers in order to function, which is needlessly inefficient. By removing the parameter and the needless inefficient helper method, the following changes: - Many Netscript functions such as isRunning() and getScript() become faster. - The terminal "tail" command now works by pid regardless of the current server. Note that "kill" already worked this way. I also improved the docs around "tail", since the pid argument wasn't in the help.
This commit is contained in:
@@ -98,12 +98,9 @@ export function findRunningScripts(
|
||||
return server.runningScriptMap.get(scriptKey(path, args)) ?? null;
|
||||
}
|
||||
|
||||
//Returns a RunningScript object matching the pid on the
|
||||
//designated server, and false otherwise
|
||||
export function findRunningScriptByPid(pid: number, server: BaseServer): RunningScript | null {
|
||||
//Returns a RunningScript object with the given pid, or null
|
||||
export function findRunningScriptByPid(pid: number): RunningScript | null {
|
||||
const ws = workerScripts.get(pid);
|
||||
// Return null if no ws found or if it's on a different server.
|
||||
if (!ws) return null;
|
||||
if (ws.scriptRef.server !== server.hostname) return null;
|
||||
return ws.scriptRef;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user