1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

Merge pull request #846 from ailin-nemui/padding

improve padding performance
This commit is contained in:
ailin-nemui 2018-02-13 12:58:07 +01:00 committed by GitHub
commit a2bc308dca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -337,11 +337,14 @@ char *get_alignment(const char *text, int align, int flags, char pad)
/* add pad characters */
if (flags & ALIGN_PAD) {
while (string_width(str->str, policy) < align) {
int pad_len = align - string_width(str->str, policy);
if (pad_len > 0) {
char *pad_full = g_strnfill(pad_len, pad);
if (flags & ALIGN_RIGHT)
g_string_prepend_c(str, pad);
g_string_prepend(str, pad_full);
else
g_string_append_c(str, pad);
g_string_append(str, pad_full);
g_free(pad_full);
}
}