From 41a11a5e83265c7718787b9cfb8b3c109c59b980 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 16 Jan 2022 00:02:16 +0100 Subject: hurd: optimize exec cleanup When ports are nul we do not need to request their deallocation. It is also useless to look for them in portnames. --- hurd/hurdexec.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'hurd') diff --git a/hurd/hurdexec.c b/hurd/hurdexec.c index d5a20cb9b0..0545935d80 100644 --- a/hurd/hurdexec.c +++ b/hurd/hurdexec.c @@ -383,19 +383,21 @@ retry: exec call. */ for (i = 0; i < _hurd_nports; ++i) - { - *pdp++ = ports[i]; - for (j = 0; j < nportnames; j++) - if (portnames[j] == ports[i]) - portnames[j] = MACH_PORT_NULL; - } + if (ports[i] != MACH_PORT_NULL) + { + *pdp++ = ports[i]; + for (j = 0; j < nportnames; j++) + if (portnames[j] == ports[i]) + portnames[j] = MACH_PORT_NULL; + } for (i = 0; i < dtablesize; ++i) - { - *pdp++ = dtable[i]; - for (j = 0; j < nportnames; j++) - if (portnames[j] == dtable[i]) - portnames[j] = MACH_PORT_NULL; - } + if (dtable[i] != MACH_PORT_NULL) + { + *pdp++ = dtable[i]; + for (j = 0; j < nportnames; j++) + if (portnames[j] == dtable[i]) + portnames[j] = MACH_PORT_NULL; + } /* Pack ports to be destroyed together. */ for (i = 0, j = 0; i < nportnames; i++) -- cgit 1.4.1