diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-07-04 21:32:15 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-07-04 21:32:15 +0000 |
commit | 7239b3a4cfa50ecd088850d13202aeff5cf96e5f (patch) | |
tree | 4474786a0cbddbb64ae072aedc5cb1b3553223fc | |
parent | ab9afc21930563eb1aa648eff269ed0234a0bbc4 (diff) | |
download | glibc-7239b3a4cfa50ecd088850d13202aeff5cf96e5f.tar glibc-7239b3a4cfa50ecd088850d13202aeff5cf96e5f.tar.gz glibc-7239b3a4cfa50ecd088850d13202aeff5cf96e5f.tar.bz2 glibc-7239b3a4cfa50ecd088850d13202aeff5cf96e5f.zip |
Update.
* posix/fnmatch_loop.c: Improve performance for single-byte
character sets by not using btowc.
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | posix/fnmatch_loop.c | 31 |
2 files changed, 32 insertions, 2 deletions
@@ -1,5 +1,8 @@ 2000-07-04 Ulrich Drepper <drepper@redhat.com> + * posix/fnmatch_loop.c: Improve performance for single-byte + character sets by not using btowc. + * posix/tst-fnmatch.input: Add tests for locale dependent behaviour. * posix/tst-fnmatch.c (main): Also set LC_CTYPE category. diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c index 3a6dffb1e4..ad729d2d8f 100644 --- a/posix/fnmatch_loop.c +++ b/posix/fnmatch_loop.c @@ -256,8 +256,35 @@ FCT (pattern, string, no_leading_period, flags) /* Invalid character class name. */ return FNM_NOMATCH; - if (ISWCTYPE (BTOWC ((UCHAR) *n), wt)) - goto matched; + /* The following code is glibc specific but does + there a good job in sppeding up the code since + we can avoid the btowc() call. The + IS_CHAR_CLASS call will return a bit mask for + the 32-bit table. We have to convert it to a + bitmask for the __ctype_b table. This has to + be done based on the byteorder as can be seen + below. In any case we will fall back on the + code using btowc() if the class is not one of + the standard classes. */ +# if defined _LIBC && ! WIDE_CHAR_VERSION +# if __BYTE_ORDER == __LITTLE_ENDIAN + if ((wt & 0xf0ffff) == 0) + { + wt >>= 16; + if ((__ctype_b[(UCHAR) *n] & wt) != 0) + goto matched; + } +# else + if (wt <= 0x800) + { + if ((__ctype_b[(UCHAR) *n] & wt) != 0) + goto matched; + } +# endif + else +# endif + if (ISWCTYPE (BTOWC ((UCHAR) *n), wt)) + goto matched; #else if ((STREQ (str, L("alnum")) && ISALNUM ((UCHAR) *n)) || (STREQ (str, L("alpha")) && ISALPHA ((UCHAR) *n)) |