Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Consolidate the "find empty string" cases. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | dgp-string-find |
Files: | files | file ages | folders |
SHA1: |
9bc07dee2411083b544e4bd3095f8125 |
User & Date: | dgp 2016-11-07 19:41:15.933 |
Context
2016-11-07
| ||
20:04 | Optimize case of all single-byte chars. Closed-Leaf check-in: e35f61d57e user: dgp tags: dgp-string-find | |
19:41 | Consolidate the "find empty string" cases. check-in: 9bc07dee24 user: dgp tags: dgp-string-find | |
19:28 | Implement direct eval [string first] with the refactored engine. check-in: 7fb4fda651 user: dgp tags: dgp-string-find | |
Changes
Changes to generic/tclStringObj.c.
︙ | ︙ | |||
2858 2859 2860 2861 2862 2863 2864 | int TclStringFind( Tcl_Obj *needle, Tcl_Obj *haystack, unsigned int start) { | > | > > > > > > > > > < < < < < < < < < < | 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 | int TclStringFind( Tcl_Obj *needle, Tcl_Obj *haystack, unsigned int start) { int lh, ln = Tcl_GetCharLength(needle); if (ln == 0) { /* * We don't find empty substrings. Bizarre! * * TODO: When we one day make this a true substring * finder, change this to "return 0" */ return -1; } if (TclIsPureByteArray(needle) && TclIsPureByteArray(haystack)) { unsigned char *end, *try, *bh; unsigned char *bn = Tcl_GetByteArrayFromObj(needle, &ln); bh = Tcl_GetByteArrayFromObj(haystack, &lh); end = bh + lh; try = bh + start; while (try + ln <= end) { try = memchr(try, bn[0], end - try); |
︙ | ︙ | |||
2898 2899 2900 2901 2902 2903 2904 | /* TODO: Detect and optimize case with single byte chars only */ { Tcl_UniChar *try, *end, *uh; Tcl_UniChar *un = Tcl_GetUnicodeFromObj(needle, &ln); | < < < < < | 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 | /* TODO: Detect and optimize case with single byte chars only */ { Tcl_UniChar *try, *end, *uh; Tcl_UniChar *un = Tcl_GetUnicodeFromObj(needle, &ln); uh = Tcl_GetUnicodeFromObj(haystack, &lh); end = uh + lh; try = uh + start; while (try + ln <= end) { if ((*try == *un) && (0 == memcmp(try+1, un+1, (ln-1)*sizeof(Tcl_UniChar)))) { |
︙ | ︙ |