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:
David Walker
2024-08-17 14:03:00 -07:00
committed by GitHub
parent 34db6e8b26
commit 5b2a4eafcb
5 changed files with 10 additions and 21 deletions
+1 -1
View File
@@ -212,7 +212,7 @@ function LogWindow({ hidden, script, onClose }: LogWindowProps): React.ReactElem
function run(): void {
const server = GetServer(script.server);
if (server === null) return;
const s = findRunningScriptByPid(script.pid, server);
const s = findRunningScriptByPid(script.pid);
if (s === null) {
const baseScript = server.scripts.get(script.filename);
if (!baseScript) {