summaryrefslogtreecommitdiffstats
path: root/src/pacman/util.h
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-03-16 23:57:04 +0100
committerDan McGee <dan@archlinux.org>2012-03-16 23:57:04 +0100
commit8da489eac53513841d62380a72aae1baecc44e61 (patch)
tree1526dbe3366f0d62d2749c3c5cd75eb80c96228e /src/pacman/util.h
parent0972b7acfd7c8fadb6aeec6606ea85bf6c5d3d3d (diff)
downloadpacman-8da489eac53513841d62380a72aae1baecc44e61.tar.gz
pacman-8da489eac53513841d62380a72aae1baecc44e61.tar.xz
Reduce calls to getcols
This dramatically improves upon a much older attempt in 2008 in commit ce3d70aa99ab86. We don't need to call it once per line we print unless there is a reasonable expectation of being able to resize the terminal mid-operation; this is really only the case during our callback progress bars. Some before and after numbers of ioctl() calls, gleaned from strace of the following operations (no targets to any of them to maximize the amount of output): pacman -Qii : 37768 -> 2616 (93.1% decrease) pacman -Qs : 2616 -> 4 (99.8%) pacman -Sii : 133036 -> 10926 (91.8%) pacman -Ss : 10926 -> 14 (99.9%) Obviously the search results are astounding; we only call getcols() once in the case of -Qs, and once per repo in the case of -Ss. For -Qii and -Sii we are still calling it once per package, but this is much better than once per line of info output. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src/pacman/util.h')
-rw-r--r--src/pacman/util.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/pacman/util.h b/src/pacman/util.h
index fc97707f..7773c81c 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -51,17 +51,21 @@ unsigned short getcols(int fd);
int rmrf(const char *path);
const char *mbasename(const char *path);
char *mdirname(const char *path);
-void indentprint(const char *str, size_t indent);
+void indentprint(const char *str, unsigned short indent, unsigned short cols);
size_t strtrim(char *str);
char *strreplace(const char *str, const char *needle, const char *replace);
alpm_list_t *strsplit(const char *str, const char splitchar);
-void string_display(const char *title, const char *string);
+void string_display(const char *title, const char *string, unsigned short cols);
double humanize_size(off_t bytes, const char target_unit, int precision,
const char **label);
-int table_display(const char *title, const alpm_list_t *header, const alpm_list_t *rows);
-void list_display(const char *title, const alpm_list_t *list);
-void list_display_linebreak(const char *title, const alpm_list_t *list);
-void signature_display(const char *title, alpm_siglist_t *siglist);
+int table_display(const char *title, const alpm_list_t *header,
+ const alpm_list_t *rows, unsigned short cols);
+void list_display(const char *title, const alpm_list_t *list,
+ unsigned short maxcols);
+void list_display_linebreak(const char *title, const alpm_list_t *list,
+ unsigned short maxcols);
+void signature_display(const char *title, alpm_siglist_t *siglist,
+ unsigned short maxcols);
void display_targets(void);
int str_cmp(const void *s1, const void *s2);
void display_new_optdepends(alpm_pkg_t *oldpkg, alpm_pkg_t *newpkg);