perf: remove redundant strlen in skipwhite

skipwhite was iterating over the input twice and scanning for the null
byte character with strlen. this is redundant, because it's already
covered by ascii_iswhite that accepts only space or tab character.

(cherry picked from commit b4743dfefa)
This commit is contained in:
ii14
2023-11-23 21:58:18 +01:00
committed by github-actions[bot]
parent c86be03216
commit 35ef7ac651

View File

@@ -1211,11 +1211,14 @@ void getvcols(win_T *wp, pos_T *pos1, pos_T *pos2, colnr_T *left, colnr_T *right
/// @param[in] p String to skip in.
///
/// @return Pointer to character after the skipped whitespace.
char *skipwhite(const char *const p)
char *skipwhite(const char *p)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
FUNC_ATTR_NONNULL_RET
{
return skipwhite_len(p, strlen(p));
while (ascii_iswhite(*p)) {
p++;
}
return (char *)p;
}
/// Like `skipwhite`, but skip up to `len` characters.