mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
perf: remove redundant strlen in skipwhite (#26177)
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. Co-authored-by: ii14 <ii14@users.noreply.github.com>
This commit is contained in:
parent
df399ea0d2
commit
32a4c9f4f9
@ -903,11 +903,14 @@ bool vim_isprintc_strict(int c)
|
|||||||
/// @param[in] p String to skip in.
|
/// @param[in] p String to skip in.
|
||||||
///
|
///
|
||||||
/// @return Pointer to character after the skipped whitespace.
|
/// @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_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
||||||
FUNC_ATTR_NONNULL_RET
|
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.
|
/// Like `skipwhite`, but skip up to `len` characters.
|
||||||
|
Loading…
Reference in New Issue
Block a user