Project

General

Profile

Bug #13397

ls calls time() many more times than necessary

Added by Peter Tribble 4 months ago. Updated 4 months ago.

Status:
New
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

Investigating why my machine was reporting such a high number of sycalls, I stumbled across this in ls.c

rep->lat.tv_sec = time(NULL);
rep->lct.tv_sec = time(NULL);
rep->lmt.tv_sec = time(NULL);

For every file, ls calls time() 3 times, and only does so to ensure the values exist - the actual time here is arbitrary, and would normally be replaced by the times from the stat structure gotten from the file.

Removing those time() calls would make ls quicker, and reduce system load.

#1

Updated by Electric Monk 4 months ago

  • Gerrit CR set to 1121

Also available in: Atom PDF