From 357b9a24a96478b7bcaaea8633f8f6a519f8903c Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 21 Jun 2014 08:44:01 -0400 Subject: cache terminal size, add SIGWINCH handler to reset Refactoring getcols, yet again. We do the following: 1) Introduce a static global in src/pacman/util.c 2) getcols always prefers this cached value, but will derive it from the COLUMNS environment var, the characteristics of stdout, or a sane default (in that order). 3) Introduce a SIGWINCH signal handler to reset the cached value, meaning we only call ioctl when we don't know the value. On my machine, pacman -Syy goes from ~4300 ioctl calls to 3. --- src/pacman/package.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pacman/package.c') diff --git a/src/pacman/package.c b/src/pacman/package.c index 3be996db..1ac0fcae 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -140,7 +140,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) optionalfor = alpm_pkg_compute_optionalfor(pkg); } - cols = getcols(fileno(stdout)); + cols = getcols(); /* actual output */ if(from == ALPM_PKG_FROM_SYNCDB) { @@ -404,7 +404,7 @@ int dump_pkg_search(alpm_db_t *db, alpm_list_t *targets, int show_status) return 1; } - cols = getcols(fileno(stdout)); + cols = getcols(); for(i = searchlist; i; i = alpm_list_next(i)) { alpm_list_t *grp; alpm_pkg_t *pkg = i->data; -- cgit v1.2.3-24-g4f1b