fb: cfb: avoid multiple `strlen` calls in `draw_text`

Added `len` to store the result of `strlen(str)` to avoid
multiple calls to `strlen` in the `for-loop`.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
This commit is contained in:
Pisit Sawangvonganan 2024-11-06 14:11:13 +07:00 committed by Anas Nashif
parent ab601ae05c
commit b7fe2a0bf9
1 changed files with 3 additions and 1 deletions

View File

@ -278,7 +278,9 @@ static int draw_text(const struct device *dev, const char *const str, int16_t x,
}
if ((fb->screen_info & SCREEN_INFO_MONO_VTILED)) {
for (size_t i = 0; i < strlen(str); i++) {
const size_t len = strlen(str);
for (size_t i = 0; i < len; i++) {
if ((x + fptr->width > fb->x_res) && wrap) {
x = 0U;
y += fptr->height;