When opening mails with slightly larger attachements in Beam, I noticed that
it was quite sluggish. When opening larger mails, like a 1.14 MB mail for example, it could take almost half a minute until it was displayed. It turned out that the offending thread was in strstr(). This is an implementation taken from Wikipedia (declared as public domain there), which makes the mails open instantly. This usecase may have represented a worst-case scenario for the previous implementation. It may be beneficial to take a look at more of these string functions, but I am happy for now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28172 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a0a1bf7fb0
commit
f73283cf6a
@ -1,26 +1,23 @@
|
||||
/*
|
||||
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
* Taken from Wikipedia, which declared it as "public domain".
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
char *
|
||||
strstr(char const *s1, char const *s2)
|
||||
strstr(const char *s1, const char *s2)
|
||||
{
|
||||
int l1, l2;
|
||||
|
||||
l2 = strlen(s2);
|
||||
if (!l2)
|
||||
return (char *)s1;
|
||||
l1 = strlen(s1);
|
||||
while (l1 >= l2) {
|
||||
l1--;
|
||||
if (!memcmp(s1,s2,l2))
|
||||
return (char *)s1;
|
||||
s1++;
|
||||
}
|
||||
return NULL;
|
||||
size_t s2len;
|
||||
/* Check for the null s2 case. */
|
||||
if (*s2 == '\0')
|
||||
return (char *) s1;
|
||||
s2len = strlen(s2);
|
||||
for (; (s1 = strchr(s1, *s2)) != NULL; s1++) {
|
||||
if (strncmp(s1, s2, s2len) == 0)
|
||||
return (char *)s1;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user