[git commit] ls: trivial code shrink

Denys Vlasenko vda.linux at googlemail.com
Wed Feb 18 10:29:07 UTC 2015


commit: http://git.busybox.net/busybox/commit/?id=0cb981c5e2f1a955e72dd9d3d2fad075dc9d0da6
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
display_single                                       914     893     -21

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 coreutils/ls.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/coreutils/ls.c b/coreutils/ls.c
index a30422a..3667583 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -566,12 +566,12 @@ static NOINLINE unsigned display_single(const struct dnode *dn)
 #if ENABLE_FEATURE_LS_TIMESTAMPS
 	if (G.all_fmt & (LIST_FULLTIME|LIST_DATE_TIME)) {
 		char *filetime;
-		time_t ttime = dn->dn_mtime;
+		time_t *ttime = &dn->dn_mtime;
 		if (G.all_fmt & TIME_ACCESS)
-			ttime = dn->dn_atime;
+			ttime = &dn->dn_atime;
 		if (G.all_fmt & TIME_CHANGE)
-			ttime = dn->dn_ctime;
-		filetime = ctime(&ttime);
+			ttime = &dn->dn_ctime;
+		filetime = ctime(ttime);
 		/* filetime's format: "Wed Jun 30 21:49:08 1993\n" */
 		if (G.all_fmt & LIST_FULLTIME) { /* -e */
 			/* Note: coreutils 8.4 ls --full-time prints:
@@ -580,7 +580,7 @@ static NOINLINE unsigned display_single(const struct dnode *dn)
 			column += printf("%.24s ", filetime);
 		} else { /* LIST_DATE_TIME */
 			/* G.current_time_t ~== time(NULL) */
-			time_t age = G.current_time_t - ttime;
+			time_t age = G.current_time_t - *ttime;
 			if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) {
 				/* less than 6 months old */
 				/* "mmm dd hh:mm " */


More information about the busybox-cvs mailing list