diff options
author | Dave Reisner <dreisner@archlinux.org> | 2014-06-21 14:44:01 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2014-06-29 03:04:17 +0200 |
commit | 357b9a24a96478b7bcaaea8633f8f6a519f8903c (patch) | |
tree | 28cdc687d3a12ab389d36758e828d17c1c13dde5 /src/pacman/util.h | |
parent | 07647d3d43d418f9efcf7c83a2079b9b673a7bfa (diff) | |
download | pacman-357b9a24a96478b7bcaaea8633f8f6a519f8903c.tar.gz pacman-357b9a24a96478b7bcaaea8633f8f6a519f8903c.tar.xz |
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.
Diffstat (limited to 'src/pacman/util.h')
-rw-r--r-- | src/pacman/util.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/pacman/util.h b/src/pacman/util.h index 4a31e89a..b591fbaf 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -49,7 +49,8 @@ int trans_init(alpm_transflag_t flags, int check_valid); int trans_release(void); int needs_root(void); int check_syncdbs(size_t need_repos, int check_valid); -unsigned short getcols(int fd); +unsigned short getcols(void); +void columns_cache_reset(void); int rmrf(const char *path); void indentprint(const char *str, unsigned short indent, unsigned short cols); size_t strtrim(char *str); |