summaryrefslogtreecommitdiff
path: root/usbredirparser
diff options
context:
space:
mode:
authorFrediano Ziglio <freddy77@gmail.com>2021-06-05 07:35:00 +0100
committerFrediano Ziglio <freddy77@gmail.com>2021-06-05 21:27:48 +0100
commit47e8f069bbf6194736596468a7b5b8ba0b7fcaff (patch)
tree62914ef9fa4d0c6b15d0f27716b3686b548b63d5 /usbredirparser
parent5b53c2518424fa9e388cfd19f1c05009462e3d1b (diff)
Small glibc_strtok_r optimization
Avoids to scan part of the string twice for the last token. Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Diffstat (limited to 'usbredirparser')
-rw-r--r--usbredirparser/strtok_r.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usbredirparser/strtok_r.c b/usbredirparser/strtok_r.c
index 227d1ea..7802962 100644
--- a/usbredirparser/strtok_r.c
+++ b/usbredirparser/strtok_r.c
@@ -51,10 +51,10 @@ glibc_strtok_r (char *s, const char *delim, char **save_ptr)
/* Find the end of the token. */
token = s;
- s = strpbrk (token, delim);
- if (s == NULL)
+ s += strcspn (token, delim);
+ if (*s == '\0')
/* This token finishes the string. */
- *save_ptr = strchr (token, '\0');
+ *save_ptr = s;
else
{
/* Terminate the token and make *SAVE_PTR point past it. */