Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Sep 2001 05:10:37 -0500
From:      Alfred Perlstein <bright@mu.org>
To:        Nick Hibma <n_hibma@FreeBSD.ORG>
Cc:        Thomas Quinot <thomas@cuivre.fr.eu.org>, current@FreeBSD.ORG
Subject:   Re: top(1) takes ages to start up
Message-ID:  <20010908051037.E2965@elvis.mu.org>
In-Reply-To: <20010908104633.P575-100000@heather.plazza.uk>; from n_hibma@FreeBSD.ORG on Sat, Sep 08, 2001 at 10:50:06AM %2B0100
References:  <20010907163406.A18904@melusine.cuivre.fr.eu.org> <20010908104633.P575-100000@heather.plazza.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
* Nick Hibma <n_hibma@FreeBSD.ORG> [010908 04:51] wrote:
> 
> Why don't you add an early-out for namelength => 15 or put the
> if-statement in the loop:

This is a good idea, however it fails for the case when everyone
has been assigned usernames that are less than 15 characters, I
would suggest putting an upper bounds on the amount of times you'll
call getpwent() to something like 200 or some other compile time
(but command line over-rideable) number before defaulting to the
max.

> 
> Index: machine.c
> ===================================================================
> RCS file: /home/ncvs/src/usr.bin/top/machine.c,v
> retrieving revision 1.44
> diff -u -r1.44 machine.c
> --- machine.c   2001/05/31 22:36:51     1.44
> +++ machine.c   2001/09/08 09:48:03
> @@ -216,13 +216,16 @@
>      while ((pw = getpwent()) != NULL) {
>         if (strlen(pw->pw_name) > namelength)
>             namelength = strlen(pw->pw_name);
> +       if (smpmode && namelength > 13) {
> +           namelength = 13;
> +           break;
> +       } else if (namelength > 15) {
> +           namelength = 15;
> +           break;
> +       }
>      }
>      if (namelength < 8)
>         namelength = 8;
> -    if (smpmode && namelength > 13)
> -       namelength = 13;
> -    else if (namelength > 15)
> -       namelength = 15;
> 
>      if ((kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY,
> "kvm_open")) == NULL)
>         return -1;
> 
> 

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010908051037.E2965>