patch 9.0.1166: code is indented more than necessary
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11792)
diff --git a/src/charset.c b/src/charset.c
index 8d7b61a..0bad471 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -345,24 +345,25 @@
}
else
res = alloc(vim_strsize(s) + 1);
- if (res != NULL)
+
+ if (res == NULL)
+ return NULL;
+
+ *res = NUL;
+ p = s;
+ while (*p != NUL)
{
- *res = NUL;
- p = s;
- while (*p != NUL)
+ if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
{
- if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
- {
- c = (*mb_ptr2char)(p);
- if (vim_isprintc(c))
- STRNCAT(res, p, l); // append printable multi-byte char
- else
- transchar_hex(res + STRLEN(res), c);
- p += l;
- }
+ c = (*mb_ptr2char)(p);
+ if (vim_isprintc(c))
+ STRNCAT(res, p, l); // append printable multi-byte char
else
- STRCAT(res, transchar_byte(*p++));
+ transchar_hex(res + STRLEN(res), c);
+ p += l;
}
+ else
+ STRCAT(res, transchar_byte(*p++));
}
return res;
}