Skip to content

Commit 5db932d

Browse files
committed
gfx_widgets_draw_task_msg - get rid of one strlen
1 parent 77da476 commit 5db932d

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

gfx/gfx_widgets.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,24 +1198,25 @@ static void gfx_widgets_draw_task_msg(
11981198
float *msg_queue_current_background;
11991199
float *msg_queue_current_bar;
12001200

1201+
size_t _len = 0;
12011202
char task_percentage[256] = "";
12021203
bool draw_msg_new = false;
1203-
unsigned task_percentage_offset = 0;
1204+
size_t task_percentage_offset = 0;
12041205

12051206
if (msg->msg_new)
12061207
draw_msg_new = !string_is_equal(msg->msg_new, msg->msg);
12071208

12081209
if (msg->flags & DISPWIDG_FLAG_TASK_FINISHED)
12091210
{
12101211
if (msg->flags & DISPWIDG_FLAG_TASK_ERROR)
1211-
strlcpy(task_percentage, msg_hash_to_str(MSG_ERROR), sizeof(task_percentage));
1212+
_len = strlcpy(task_percentage, msg_hash_to_str(MSG_ERROR), sizeof(task_percentage));
12121213
}
12131214
else if (msg->task_progress >= 0 && msg->task_progress <= 100)
1214-
snprintf(task_percentage, sizeof(task_percentage),
1215+
_len = snprintf(task_percentage, sizeof(task_percentage),
12151216
"%i%%", msg->task_progress);
12161217

1217-
task_percentage_offset = p_dispwidget->gfx_widget_fonts.msg_queue.glyph_width * strlen(task_percentage);
1218-
rect_width = p_dispwidget->msg_queue_padding * 5.0f + msg->width + task_percentage_offset;
1218+
task_percentage_offset = p_dispwidget->gfx_widget_fonts.msg_queue.glyph_width * _len;
1219+
rect_width = p_dispwidget->msg_queue_padding * 5.0f + msg->width + task_percentage_offset;
12191220
bar_width = rect_width * msg->task_progress/100.0f;
12201221
text_color = COLOR_TEXT_ALPHA(0xFFFFFF00, (unsigned)(msg->alpha*255.0f));
12211222

@@ -1588,7 +1589,7 @@ void gfx_widgets_frame(void *data)
15881589
0.00, 1.00, 0.00, 1.00,
15891590
0.00, 1.00, 0.00, 1.00,
15901591
};
1591-
1592+
15921593
gfx_display_set_alpha(p_dispwidget->pure_white, 1.0f);
15931594

15941595
if (p_dispwidget->ai_service_overlay_texture)
@@ -1669,7 +1670,7 @@ void gfx_widgets_frame(void *data)
16691670
video_height,
16701671
outline_color,
16711672
NULL
1672-
);
1673+
);
16731674
if (p_dispwidget->ai_service_overlay_state == 2)
16741675
p_dispwidget->ai_service_overlay_state = 3;
16751676
}

0 commit comments

Comments
 (0)