forked from external/yambar
particle/string: simplify; no need to call c32len(wtext) twice
This commit is contained in:
parent
36a4250a96
commit
1b03bd6bc0
1 changed files with 13 additions and 17 deletions
|
@ -179,10 +179,7 @@ instantiate(const struct particle *particle, const struct tag_set *tags)
|
||||||
size_t chars = c32len(wtext);
|
size_t chars = c32len(wtext);
|
||||||
|
|
||||||
/* Truncate, if necessary */
|
/* Truncate, if necessary */
|
||||||
if (p->max_len > 0) {
|
if (p->max_len > 0 && chars > p->max_len) {
|
||||||
const size_t len = c32len(wtext);
|
|
||||||
if (len > p->max_len) {
|
|
||||||
|
|
||||||
size_t end = p->max_len;
|
size_t end = p->max_len;
|
||||||
if (end >= 1) {
|
if (end >= 1) {
|
||||||
/* "allocate" room for three dots at the end */
|
/* "allocate" room for three dots at the end */
|
||||||
|
@ -198,7 +195,6 @@ instantiate(const struct particle *particle, const struct tag_set *tags)
|
||||||
chars = 0;
|
chars = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
e->kern_x = calloc(chars, sizeof(e->kern_x[0]));
|
e->kern_x = calloc(chars, sizeof(e->kern_x[0]));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue