diff options
| author | joerg <joerg@NetBSD.org> | 2011-11-22 00:37:09 +0000 |
|---|---|---|
| committer | joerg <joerg@NetBSD.org> | 2011-11-22 00:37:09 +0000 |
| commit | 6c8ad274aaa7a3b7d5e588d5ff0819b4ae1443cb (patch) | |
| tree | 150f7644bf7794972a28f6528fd882b4011ce991 /lib/libc/string | |
| parent | cf5b206fe31d956c20cd5d331a7352f202f2d265 (diff) | |
Handle simple cases (strlen(charset) <= 1) more efficiently.
Diffstat (limited to 'lib/libc/string')
| -rw-r--r-- | lib/libc/string/strpbrk.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libc/string/strpbrk.c b/lib/libc/string/strpbrk.c index 095b9b266b2..7f4f822ebbb 100644 --- a/lib/libc/string/strpbrk.c +++ b/lib/libc/string/strpbrk.c @@ -1,4 +1,4 @@ -/* $NetBSD: strpbrk.c,v 1.19 2008/09/24 16:58:53 christos Exp $ */ +/* $NetBSD: strpbrk.c,v 1.20 2011/11/22 00:37:09 joerg Exp $ */ /*- * Copyright (c) 2008 Joerg Sonnenberger @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: strpbrk.c,v 1.19 2008/09/24 16:58:53 christos Exp $"); +__RCSID("$NetBSD: strpbrk.c,v 1.20 2011/11/22 00:37:09 joerg Exp $"); #include <assert.h> #include <inttypes.h> @@ -60,6 +60,11 @@ strpbrk(const char *s, const char *charset) _DIAGASSERT(s != NULL); _DIAGASSERT(charset != NULL); + if (charset[0] == '\0') + return NULL; + if (charset[1] == '\0') + return strchr(s, charset[0]); + for (; *charset != '\0'; ++charset) ADD_TO_SET(UC(*charset)); |
