aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorii14 <59243201+ii14@users.noreply.github.com>2023-11-23 22:26:33 +0100
committerGitHub <noreply@github.com>2023-11-24 05:26:33 +0800
commit32a4c9f4f92dc9371a1a6ee053223babca89d4a1 (patch)
tree4f5989eaac2d1beab39a60e32876170d55445d28
parentdf399ea0d20e86027d0b59ca4bbd445c1d035a67 (diff)
downloadrneovim-32a4c9f4f92dc9371a1a6ee053223babca89d4a1.tar.gz
rneovim-32a4c9f4f92dc9371a1a6ee053223babca89d4a1.tar.bz2
rneovim-32a4c9f4f92dc9371a1a6ee053223babca89d4a1.zip
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>
-rw-r--r--src/nvim/charset.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 5dfc9c444d..9a7de8ecef 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -903,11 +903,14 @@ bool vim_isprintc_strict(int c)
/// @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.