From d138cbfb47e379edc1ee915a8c6ff65b01f000d6 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 3 Apr 2020 19:15:01 +0200 Subject: Code Quality: Replace for loops with LISTBASE_FOREACH Note this only changes cases where the variable was declared inside the for loop. To handle it outside as well is a different challenge. Differential Revision: https://developer.blender.org/D7320 --- source/blender/blenkernel/intern/text.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern/text.c') diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 94c41777cea..3cdf3b40ce3 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -164,7 +164,7 @@ static void text_copy_data(Main *UNUSED(bmain), text_dst->compiled = NULL; /* Walk down, reconstructing. */ - for (TextLine *line_src = text_src->lines.first; line_src; line_src = line_src->next) { + LISTBASE_FOREACH (TextLine *, line_src, &text_src->lines) { TextLine *line_dst = MEM_mallocN(sizeof(*line_dst), __func__); line_dst->line = BLI_strdup(line_src->line); @@ -1311,12 +1311,12 @@ void txt_sel_set(Text *text, int startl, int startc, int endl, int endc) char *txt_to_buf_for_undo(Text *text, int *r_buf_len) { int buf_len = 0; - for (const TextLine *l = text->lines.first; l; l = l->next) { + LISTBASE_FOREACH (const TextLine *, l, &text->lines) { buf_len += l->len + 1; } char *buf = MEM_mallocN(buf_len, __func__); char *buf_step = buf; - for (const TextLine *l = text->lines.first; l; l = l->next) { + LISTBASE_FOREACH (const TextLine *, l, &text->lines) { memcpy(buf_step, l->line, l->len); buf_step += l->len; *buf_step++ = '\n'; -- cgit v1.2.3