Small optimization: set use_ampm only when needed
This commit is contained in:
parent
e25fd27cd1
commit
f59105eedb
@ -41,7 +41,7 @@ struct varent;
|
|||||||
|
|
||||||
extern fixpt_t ccpu;
|
extern fixpt_t ccpu;
|
||||||
extern int eval, fscale, mempages, nlistread, rawcpu, cflag;
|
extern int eval, fscale, mempages, nlistread, rawcpu, cflag;
|
||||||
extern int sumrusage, termwidth, totwidth, use_ampm;
|
extern int sumrusage, termwidth, totwidth;
|
||||||
extern VAR var[];
|
extern VAR var[];
|
||||||
extern VARENT *vhead;
|
extern VARENT *vhead;
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ static const char rcsid[] =
|
|||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <langinfo.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <nlist.h>
|
#include <nlist.h>
|
||||||
@ -354,6 +355,7 @@ started(k, ve)
|
|||||||
time_t then;
|
time_t then;
|
||||||
struct tm *tp;
|
struct tm *tp;
|
||||||
char buf[100];
|
char buf[100];
|
||||||
|
static int use_ampm = -1;
|
||||||
|
|
||||||
v = ve->var;
|
v = ve->var;
|
||||||
if (!k->ki_valid) {
|
if (!k->ki_valid) {
|
||||||
@ -361,6 +363,9 @@ started(k, ve)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (use_ampm < 0)
|
||||||
|
use_ampm = (*nl_langinfo(T_FMT_AMPM) != '\0');
|
||||||
|
|
||||||
then = k->ki_p->ki_start.tv_sec;
|
then = k->ki_p->ki_start.tv_sec;
|
||||||
tp = localtime(&then);
|
tp = localtime(&then);
|
||||||
if (!now)
|
if (!now)
|
||||||
|
@ -58,7 +58,6 @@ static const char rcsid[] =
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <kvm.h>
|
#include <kvm.h>
|
||||||
#include <langinfo.h>
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <nlist.h>
|
#include <nlist.h>
|
||||||
@ -83,7 +82,6 @@ int rawcpu; /* -C */
|
|||||||
int sumrusage; /* -S */
|
int sumrusage; /* -S */
|
||||||
int termwidth; /* width of screen (0 == infinity) */
|
int termwidth; /* width of screen (0 == infinity) */
|
||||||
int totwidth; /* calculated width of requested variables */
|
int totwidth; /* calculated width of requested variables */
|
||||||
int use_ampm; /* use AM/PM time */
|
|
||||||
|
|
||||||
static int needuser, needcomm, needenv;
|
static int needuser, needcomm, needenv;
|
||||||
#if defined(LAZY_PS)
|
#if defined(LAZY_PS)
|
||||||
@ -131,7 +129,6 @@ main(argc, argv)
|
|||||||
char *nlistf, *memf, *swapf, errbuf[_POSIX2_LINE_MAX];
|
char *nlistf, *memf, *swapf, errbuf[_POSIX2_LINE_MAX];
|
||||||
|
|
||||||
(void) setlocale(LC_ALL, "");
|
(void) setlocale(LC_ALL, "");
|
||||||
use_ampm = (*nl_langinfo(T_FMT_AMPM) != '\0');
|
|
||||||
|
|
||||||
if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
|
if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
|
||||||
ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
|
ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user