summaryrefslogtreecommitdiffstats
path: root/bin/ps
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-03-03 01:46:58 +0000
committerache <ache@FreeBSD.org>2001-03-03 01:46:58 +0000
commit2c96c2d1775e08b05f1405f4555b497b14d6dbc4 (patch)
tree7e60b0cde63f7c63a85403bdd4899e9acee38bae /bin/ps
parent1172de03441c7065530b581a78ba2b1403593c21 (diff)
downloadFreeBSD-src-2c96c2d1775e08b05f1405f4555b497b14d6dbc4.zip
FreeBSD-src-2c96c2d1775e08b05f1405f4555b497b14d6dbc4.tar.gz
Small optimization: set use_ampm only when needed
Diffstat (limited to 'bin/ps')
-rw-r--r--bin/ps/extern.h2
-rw-r--r--bin/ps/print.c5
-rw-r--r--bin/ps/ps.c3
3 files changed, 6 insertions, 4 deletions
diff --git a/bin/ps/extern.h b/bin/ps/extern.h
index 5579669..dedac7e 100644
--- a/bin/ps/extern.h
+++ b/bin/ps/extern.h
@@ -41,7 +41,7 @@ struct varent;
extern fixpt_t ccpu;
extern int eval, fscale, mempages, nlistread, rawcpu, cflag;
-extern int sumrusage, termwidth, totwidth, use_ampm;
+extern int sumrusage, termwidth, totwidth;
extern VAR var[];
extern VARENT *vhead;
diff --git a/bin/ps/print.c b/bin/ps/print.c
index 37d03a3..f73c3f0 100644
--- a/bin/ps/print.c
+++ b/bin/ps/print.c
@@ -51,6 +51,7 @@ static const char rcsid[] =
#include <vm/vm.h>
#include <err.h>
+#include <langinfo.h>
#include <locale.h>
#include <math.h>
#include <nlist.h>
@@ -354,6 +355,7 @@ started(k, ve)
time_t then;
struct tm *tp;
char buf[100];
+ static int use_ampm = -1;
v = ve->var;
if (!k->ki_valid) {
@@ -361,6 +363,9 @@ started(k, ve)
return;
}
+ if (use_ampm < 0)
+ use_ampm = (*nl_langinfo(T_FMT_AMPM) != '\0');
+
then = k->ki_p->ki_start.tv_sec;
tp = localtime(&then);
if (!now)
diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index 7d5aaee..55fdc07 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -58,7 +58,6 @@ static const char rcsid[] =
#include <errno.h>
#include <fcntl.h>
#include <kvm.h>
-#include <langinfo.h>
#include <limits.h>
#include <locale.h>
#include <nlist.h>
@@ -83,7 +82,6 @@ int rawcpu; /* -C */
int sumrusage; /* -S */
int termwidth; /* width of screen (0 == infinity) */
int totwidth; /* calculated width of requested variables */
-int use_ampm; /* use AM/PM time */
static int needuser, needcomm, needenv;
#if defined(LAZY_PS)
@@ -131,7 +129,6 @@ main(argc, argv)
char *nlistf, *memf, *swapf, errbuf[_POSIX2_LINE_MAX];
(void) setlocale(LC_ALL, "");
- use_ampm = (*nl_langinfo(T_FMT_AMPM) != '\0');
if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
OpenPOWER on IntegriCloud