Module Name: src Committed By: joerg Date: Tue Nov 22 00:37:10 UTC 2011
Modified Files: src/lib/libc/string: strpbrk.c Log Message: Handle simple cases (strlen(charset) <= 1) more efficiently. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/lib/libc/string/strpbrk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/string/strpbrk.c diff -u src/lib/libc/string/strpbrk.c:1.19 src/lib/libc/string/strpbrk.c:1.20 --- src/lib/libc/string/strpbrk.c:1.19 Wed Sep 24 16:58:53 2008 +++ src/lib/libc/string/strpbrk.c Tue Nov 22 00:37:09 2011 @@ -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 *chars _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));