Skip to content

Commit b7fe2a0

Browse files
ndrs-pstnashif
authored andcommitted
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 <[email protected]>
1 parent ab601ae commit b7fe2a0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

subsys/fb/cfb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,9 @@ static int draw_text(const struct device *dev, const char *const str, int16_t x,
278278
}
279279

280280
if ((fb->screen_info & SCREEN_INFO_MONO_VTILED)) {
281-
for (size_t i = 0; i < strlen(str); i++) {
281+
const size_t len = strlen(str);
282+
283+
for (size_t i = 0; i < len; i++) {
282284
if ((x + fptr->width > fb->x_res) && wrap) {
283285
x = 0U;
284286
y += fptr->height;

0 commit comments

Comments
 (0)