Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/string Handle simple cases (strlen(charset) <= 1) m...



details:   https://anonhg.NetBSD.org/src/rev/a832ac47be65
branches:  trunk
changeset: 771470:a832ac47be65
user:      joerg <joerg%NetBSD.org@localhost>
date:      Tue Nov 22 00:37:09 2011 +0000

description:
Handle simple cases (strlen(charset) <= 1) more efficiently.

diffstat:

 lib/libc/string/strpbrk.c |  9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diffs (30 lines):

diff -r d911d6db4551 -r a832ac47be65 lib/libc/string/strpbrk.c
--- a/lib/libc/string/strpbrk.c Mon Nov 21 23:50:44 2011 +0000
+++ b/lib/libc/string/strpbrk.c Tue Nov 22 00:37:09 2011 +0000
@@ -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 @@
        _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));
 



Home | Main Index | Thread Index | Old Index