particle/string: simplify; no need to call c32len(wtext) twice

This commit is contained in:
Daniel Eklöf 2022-06-13 12:06:59 +02:00
parent 36a4250a96
commit 1b03bd6bc0
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -179,10 +179,7 @@ instantiate(const struct particle *particle, const struct tag_set *tags)
size_t chars = c32len(wtext);
/* Truncate, if necessary */
if (p->max_len > 0) {
const size_t len = c32len(wtext);
if (len > p->max_len) {
if (p->max_len > 0 && chars > p->max_len) {
size_t end = p->max_len;
if (end >= 1) {
/* "allocate" room for three dots at the end */
@ -198,7 +195,6 @@ instantiate(const struct particle *particle, const struct tag_set *tags)
chars = 0;
}
}
}
e->kern_x = calloc(chars, sizeof(e->kern_x[0]));