mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-25 06:09:38 +03:00
in nstrcasestr(), mbstrcasestr(), revstrstr(), revstrcasestr(), and
mbrevstrcasestr(), for efficiency, return haystack immediately if needle is blank git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4122 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
444f802d58
commit
710583064f
@ -1,3 +1,9 @@
|
||||
2007-07-02 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
|
||||
* chars.c (nstrcasestr, mbstrcasestr, revstrstr, revstrcasestr,
|
||||
mbrevstrcasestr): For efficiency, return haystack immediately if
|
||||
needle is blank.
|
||||
|
||||
2007-07-01 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
|
||||
* chars.c (nstrncasecmp, mbstrncasecmp): For efficiency, return
|
||||
|
15
src/chars.c
15
src/chars.c
@ -606,6 +606,9 @@ const char *nstrcasestr(const char *haystack, const char *needle)
|
||||
{
|
||||
assert(haystack != NULL && needle != NULL);
|
||||
|
||||
if (needle == '\0')
|
||||
return haystack;
|
||||
|
||||
for (; *haystack != '\0'; haystack++) {
|
||||
const char *r = haystack, *q = needle;
|
||||
|
||||
@ -631,6 +634,9 @@ const char *mbstrcasestr(const char *haystack, const char *needle)
|
||||
|
||||
assert(haystack != NULL && needle != NULL);
|
||||
|
||||
if (needle == '\0')
|
||||
return haystack;
|
||||
|
||||
r_mb = charalloc(MB_CUR_MAX);
|
||||
q_mb = charalloc(MB_CUR_MAX);
|
||||
|
||||
@ -690,6 +696,9 @@ const char *revstrstr(const char *haystack, const char *needle, const
|
||||
{
|
||||
assert(haystack != NULL && needle != NULL && rev_start != NULL);
|
||||
|
||||
if (needle == '\0')
|
||||
return rev_start;
|
||||
|
||||
for (; rev_start >= haystack; rev_start--) {
|
||||
const char *r, *q;
|
||||
|
||||
@ -712,6 +721,9 @@ const char *revstrcasestr(const char *haystack, const char *needle,
|
||||
{
|
||||
assert(haystack != NULL && needle != NULL && rev_start != NULL);
|
||||
|
||||
if (needle == '\0')
|
||||
return rev_start;
|
||||
|
||||
for (; rev_start >= haystack; rev_start--) {
|
||||
const char *r = rev_start, *q = needle;
|
||||
|
||||
@ -739,6 +751,9 @@ const char *mbrevstrcasestr(const char *haystack, const char *needle,
|
||||
|
||||
assert(haystack != NULL && needle != NULL && rev_start != NULL);
|
||||
|
||||
if (needle == '\0')
|
||||
return rev_start;
|
||||
|
||||
r_mb = charalloc(MB_CUR_MAX);
|
||||
q_mb = charalloc(MB_CUR_MAX);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user