diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-03-20 20:29:25 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-03-20 20:29:25 (GMT) |
commit | 8af92a8a6b470126d931eff19d97f7630f618006 (patch) | |
tree | ba0c6e7a1024d982938235931b0d1067bd1d9197 /generic | |
parent | c820318356373338e81456fc7f995e2e19c0218c (diff) | |
parent | ab2ee17c917d4c1ac391bc15fe68a87e672f2f73 (diff) | |
download | tcl-8af92a8a6b470126d931eff19d97f7630f618006.zip tcl-8af92a8a6b470126d931eff19d97f7630f618006.tar.gz tcl-8af92a8a6b470126d931eff19d97f7630f618006.tar.bz2 |
Fix [6811a00819]: lsearch performance degradation on Tcl 8.6.11 release (thanks, Sergey!)
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclBinary.c | 8 | ||||
-rw-r--r-- | generic/tclCmdIL.c | 4 | ||||
-rw-r--r-- | generic/tclCmdMZ.c | 8 | ||||
-rw-r--r-- | generic/tclCompExpr.c | 4 | ||||
-rw-r--r-- | generic/tclDisassemble.c | 2 | ||||
-rw-r--r-- | generic/tclEncoding.c | 12 | ||||
-rw-r--r-- | generic/tclInt.h | 7 | ||||
-rw-r--r-- | generic/tclParse.c | 4 | ||||
-rw-r--r-- | generic/tclScan.c | 2 | ||||
-rw-r--r-- | generic/tclStringObj.c | 4 | ||||
-rw-r--r-- | generic/tclStubInit.c | 4 | ||||
-rw-r--r-- | generic/tclUtf.c | 20 | ||||
-rw-r--r-- | generic/tclUtil.c | 30 |
13 files changed, 48 insertions, 61 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 916ba4c..9dd9edf 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -512,7 +512,7 @@ MakeByteArray( for (; src < srcEnd && dst < dstEnd; ) { int ch; - int count = Tcl_UtfToUniChar(src, &ch); + int count = TclUtfToUniChar(src, &ch); if (ch > 255) { proper = 0; @@ -2563,7 +2563,7 @@ BinaryDecodeHex( if (pure) { ucs4 = c; } else { - Tcl_UtfToUniChar((const char *)(data - 1), &ucs4); + TclUtfToUniChar((const char *)(data - 1), &ucs4); } TclDecrRefCount(resultObj); Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -3028,7 +3028,7 @@ BinaryDecodeUu( if (pure) { ucs4 = c; } else { - Tcl_UtfToUniChar((const char *)(data - 1), &ucs4); + TclUtfToUniChar((const char *)(data - 1), &ucs4); } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid uuencode character \"%c\" (U+%06X) at position %" @@ -3203,7 +3203,7 @@ BinaryDecode64( * of a multi-byte character. */ /* Safe because we know data is NUL-terminated */ - Tcl_UtfToUniChar((const char *)(data - 1), &ucs4); + TclUtfToUniChar((const char *)(data - 1), &ucs4); } Tcl_SetObjResult(interp, Tcl_ObjPrintf( diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 4474513..c79fd86 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -5432,8 +5432,8 @@ DictionaryCompare( */ if ((*left != '\0') && (*right != '\0')) { - left += Tcl_UtfToUniChar(left, &uniLeft); - right += Tcl_UtfToUniChar(right, &uniRight); + left += TclUtfToUniChar(left, &uniLeft); + right += TclUtfToUniChar(right, &uniRight); /* * Convert both chars to lower for the comparison, because diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 56d4cca..a00762e 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -1220,7 +1220,7 @@ Tcl_SplitObjCmd( Tcl_InitHashTable(&charReuseTable, TCL_ONE_WORD_KEYS); for ( ; stringPtr < end; stringPtr += len) { - len = Tcl_UtfToUniChar(stringPtr, &ch); + len = TclUtfToUniChar(stringPtr, &ch); hPtr = Tcl_CreateHashEntry(&charReuseTable, INT2PTR(ch), &isNew); if (isNew) { TclNewStringObj(objPtr, stringPtr, len); @@ -1266,9 +1266,9 @@ Tcl_SplitObjCmd( splitEnd = splitChars + splitCharLen; for (element = stringPtr; stringPtr < end; stringPtr += len) { - len = Tcl_UtfToUniChar(stringPtr, &ch); + len = TclUtfToUniChar(stringPtr, &ch); for (p = splitChars; p < splitEnd; p += splitLen) { - splitLen = Tcl_UtfToUniChar(p, &splitChar); + splitLen = TclUtfToUniChar(p, &splitChar); if (ch == splitChar) { TclNewStringObj(objPtr, element, stringPtr - element); Tcl_ListObjAppendElement(NULL, listPtr, objPtr); @@ -1891,7 +1891,7 @@ StringIsCmd( for (; string1 < end; string1 += length2, failat++) { int ucs4; - length2 = Tcl_UtfToUniChar(string1, &ucs4); + length2 = TclUtfToUniChar(string1, &ucs4); if (!chcomp(ucs4)) { result = 0; break; diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c index 85f475e..e7ea456 100644 --- a/generic/tclCompExpr.c +++ b/generic/tclCompExpr.c @@ -2149,13 +2149,13 @@ ParseLexeme( if (!TclIsBareword(*start) || *start == '_') { Tcl_Size scanned; if (Tcl_UtfCharComplete(start, numBytes)) { - scanned = Tcl_UtfToUniChar(start, &ch); + scanned = TclUtfToUniChar(start, &ch); } else { char utfBytes[8]; memcpy(utfBytes, start, numBytes); utfBytes[numBytes] = '\0'; - scanned = Tcl_UtfToUniChar(utfBytes, &ch); + scanned = TclUtfToUniChar(utfBytes, &ch); } *lexemePtr = INVALID; Tcl_DecrRefCount(literal); diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c index 1a41562..68b3b6c 100644 --- a/generic/tclDisassemble.c +++ b/generic/tclDisassemble.c @@ -876,7 +876,7 @@ PrintSourceToObj( for (; (*p != '\0') && (i < maxChars); p+=len) { int ucs4; - len = Tcl_UtfToUniChar(p, &ucs4); + len = TclUtfToUniChar(p, &ucs4); switch (ucs4) { case '"': Tcl_AppendToObj(appendObj, "\\\"", -1); diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 074c58e..312ce85 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -1581,7 +1581,7 @@ Tcl_UtfToExternalDStringEx( int ucs4; char buf[TCL_INTEGER_SPACE]; - Tcl_UtfToUniChar(&srcStart[nBytesProcessed], &ucs4); + TclUtfToUniChar(&srcStart[nBytesProcessed], &ucs4); snprintf(buf, sizeof(buf), "%" TCL_SIZE_MODIFIER "d", nBytesProcessed); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unexpected character at index %" TCL_SIZE_MODIFIER @@ -2551,11 +2551,11 @@ UtfToUtfProc( /* TCL_ENCODING_PROFILE_TCL8 */ char chbuf[2]; chbuf[0] = UCHAR(*src++); chbuf[1] = 0; - Tcl_UtfToUniChar(chbuf, &ch); + TclUtfToUniChar(chbuf, &ch); } dst += Tcl_UniCharToUtf(ch, dst); } else { - size_t len = Tcl_UtfToUniChar(src, &ch); + size_t len = TclUtfToUniChar(src, &ch); if (flags & ENCODING_INPUT) { if (((len < 2) && (ch != 0)) || ((ch > 0xFFFF) && !(flags & ENCODING_UTF))) { if (PROFILE_STRICT(profile)) { @@ -2799,7 +2799,7 @@ UtfToUtf32Proc( result = TCL_CONVERT_NOSPACE; break; } - len = Tcl_UtfToUniChar(src, &ch); + len = TclUtfToUniChar(src, &ch); if (SURROGATE(ch)) { if (PROFILE_STRICT(flags)) { result = TCL_CONVERT_UNKNOWN; @@ -3076,7 +3076,7 @@ UtfToUtf16Proc( result = TCL_CONVERT_NOSPACE; break; } - len = Tcl_UtfToUniChar(src, &ch); + len = TclUtfToUniChar(src, &ch); if (SURROGATE(ch)) { if (PROFILE_STRICT(flags)) { result = TCL_CONVERT_UNKNOWN; @@ -3323,7 +3323,7 @@ TableToUtfProc( } else { char chbuf[2]; chbuf[0] = byte; chbuf[1] = 0; - Tcl_UtfToUniChar(chbuf, &ch); + TclUtfToUniChar(chbuf, &ch); } } diff --git a/generic/tclInt.h b/generic/tclInt.h index ada17b3..50c7add 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4565,17 +4565,10 @@ MODULE_SCOPE const TclFileAttrProcs tclpFileAttrProcs[]; *---------------------------------------------------------------- */ -#if TCL_UTF_MAX > 3 #define TclUtfToUniChar(str, chPtr) \ (((UCHAR(*(str))) < 0x80) ? \ ((*(chPtr) = UCHAR(*(str))), 1) \ : Tcl_UtfToUniChar(str, chPtr)) -#else -#define TclUtfToUniChar(str, chPtr) \ - (((UCHAR(*(str))) < 0x80) ? \ - ((*(chPtr) = UCHAR(*(str))), 1) \ - : Tcl_UtfToChar16(str, chPtr)) -#endif /* *---------------------------------------------------------------- diff --git a/generic/tclParse.c b/generic/tclParse.c index 84200ac..92ec1c2 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -926,13 +926,13 @@ TclParseBackslash( */ if (Tcl_UtfCharComplete(p, numBytes - 1)) { - count = Tcl_UtfToUniChar(p, &unichar) + 1; /* +1 for '\' */ + count = TclUtfToUniChar(p, &unichar) + 1; /* +1 for '\' */ } else { char utfBytes[8]; memcpy(utfBytes, p, numBytes - 1); utfBytes[numBytes - 1] = '\0'; - count = Tcl_UtfToUniChar(utfBytes, &unichar) + 1; + count = TclUtfToUniChar(utfBytes, &unichar) + 1; } result = unichar; break; diff --git a/generic/tclScan.c b/generic/tclScan.c index 195153b..71af1f2 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -902,7 +902,7 @@ Tcl_ScanObjCmd( * Scan a single Unicode character. */ - offset = Tcl_UtfToUniChar(string, &i); + offset = TclUtfToUniChar(string, &i); string += offset; if (!(flags & SCAN_SUPPRESS)) { TclNewIntObj(objPtr, i); diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index d8b96f7..dba36a6 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -618,8 +618,6 @@ TclGetUniChar( return -1; } const char *begin = TclUtfAtIndex(objPtr->bytes, index); -#undef Tcl_UtfToUniChar - Tcl_UtfToUniChar(begin, &ch); return ch; } @@ -4133,7 +4131,7 @@ TclStringReverse( * skip calling Tcl_UtfCharComplete() here. */ - int bytesInChar = Tcl_UtfToUniChar(from, &chw); + int bytesInChar = TclUtfToUniChar(from, &chw); ReverseBytes((unsigned char *)to, (unsigned char *)from, bytesInChar); diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 6b1dea2..e35a401 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -64,10 +64,6 @@ #undef Tcl_ParseArgsObjv #undef TclStaticLibrary #define TclStaticLibrary Tcl_StaticLibrary -#undef Tcl_UniCharToUtfDString -#undef Tcl_UtfToUniCharDString -#undef Tcl_UtfToUniChar -#undef Tcl_UniCharLen #undef TclObjInterpProc #if !defined(_WIN32) && !defined(__CYGWIN__) # undef Tcl_WinConvertError diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 3dede09..e107081 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -678,11 +678,11 @@ Tcl_UtfToUniCharDString( endPtr = src + length; optPtr = endPtr - 4; while (p <= optPtr) { - p += Tcl_UtfToUniChar(p, &ch); + p += TclUtfToUniChar(p, &ch); *w++ = ch; } while ((p < endPtr) && Tcl_UtfCharComplete(p, endPtr-p)) { - p += Tcl_UtfToUniChar(p, &ch); + p += TclUtfToUniChar(p, &ch); *w++ = ch; } while (p < endPtr) { @@ -928,7 +928,7 @@ Tcl_UtfFindFirst( int ch) /* The Unicode character to search for. */ { while (1) { - int find, len = Tcl_UtfToUniChar(src, &find); + int find, len = TclUtfToUniChar(src, &find); if (find == ch) { return src; @@ -967,7 +967,7 @@ Tcl_UtfFindLast( const char *last = NULL; while (1) { - int find, len = Tcl_UtfToUniChar(src, &find); + int find, len = TclUtfToUniChar(src, &find); if (find == ch) { last = src; @@ -1190,7 +1190,7 @@ Tcl_UniCharAtIndex( i = TclUtfToUniChar(src, &ch); src += i; } - Tcl_UtfToUniChar(src, &i); + TclUtfToUniChar(src, &i); return i; } @@ -1219,7 +1219,7 @@ Tcl_UtfAtIndex( Tcl_UniChar ch = 0; while (index-- > 0) { - src += Tcl_UtfToUniChar(src, &ch); + src += TclUtfToUniChar(src, &ch); } return src; } @@ -1329,7 +1329,7 @@ Tcl_UtfToUpper( src = dst = str; while (*src) { - len = Tcl_UtfToUniChar(src, &ch); + len = TclUtfToUniChar(src, &ch); upChar = Tcl_UniCharToUpper(ch); /* @@ -1382,7 +1382,7 @@ Tcl_UtfToLower( src = dst = str; while (*src) { - len = Tcl_UtfToUniChar(src, &ch); + len = TclUtfToUniChar(src, &ch); lowChar = Tcl_UniCharToLower(ch); /* @@ -1438,7 +1438,7 @@ Tcl_UtfToTitle( src = dst = str; if (*src) { - len = Tcl_UtfToUniChar(src, &ch); + len = TclUtfToUniChar(src, &ch); titleChar = Tcl_UniCharToTitle(ch); if (len < TclUtfCount(titleChar)) { @@ -1450,7 +1450,7 @@ Tcl_UtfToTitle( src += len; } while (*src) { - len = Tcl_UtfToUniChar(src, &ch); + len = TclUtfToUniChar(src, &ch); lowChar = ch; /* Special exception for Georgian Asomtavruli chars, no titlecase. */ if ((unsigned)(lowChar - 0x1C90) >= 0x30) { diff --git a/generic/tclUtil.c b/generic/tclUtil.c index efe7ea9..e15a18f 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -1672,7 +1672,7 @@ TclTrimRight( pp = Tcl_UtfPrev(p, bytes); do { pp += pInc; - pInc = Tcl_UtfToUniChar(pp, &ch1); + pInc = TclUtfToUniChar(pp, &ch1); } while (pp + pInc < p); /* @@ -1680,7 +1680,7 @@ TclTrimRight( */ do { - pInc = Tcl_UtfToUniChar(q, &ch2); + pInc = TclUtfToUniChar(q, &ch2); if (ch1 == ch2) { break; @@ -1745,7 +1745,7 @@ TclTrimLeft( */ do { - Tcl_Size pInc = Tcl_UtfToUniChar(p, &ch1); + Tcl_Size pInc = TclUtfToUniChar(p, &ch1); const char *q = trim; Tcl_Size bytesLeft = numTrim; @@ -1754,7 +1754,7 @@ TclTrimLeft( */ do { - Tcl_Size qInc = Tcl_UtfToUniChar(q, &ch2); + Tcl_Size qInc = TclUtfToUniChar(q, &ch2); if (ch1 == ch2) { break; @@ -1821,7 +1821,7 @@ TclTrim( if (numBytes > 0) { int ch; const char *first = bytes + trimLeft; - bytes += Tcl_UtfToUniChar(first, &ch); + bytes += TclUtfToUniChar(first, &ch); numBytes -= (bytes - first); if (numBytes > 0) { @@ -2151,7 +2151,7 @@ Tcl_StringCaseMatch( ch2 = (int) (nocase ? tolower(UCHAR(*pattern)) : UCHAR(*pattern)); } else { - Tcl_UtfToUniChar(pattern, &ch2); + TclUtfToUniChar(pattern, &ch2); if (nocase) { ch2 = Tcl_UniCharToLower(ch2); } @@ -2167,7 +2167,7 @@ Tcl_StringCaseMatch( if ((p != '[') && (p != '?') && (p != '\\')) { if (nocase) { while (*str) { - charLen = Tcl_UtfToUniChar(str, &ch1); + charLen = TclUtfToUniChar(str, &ch1); if (ch2==ch1 || ch2==Tcl_UniCharToLower(ch1)) { break; } @@ -2181,7 +2181,7 @@ Tcl_StringCaseMatch( */ while (*str) { - charLen = Tcl_UtfToUniChar(str, &ch1); + charLen = TclUtfToUniChar(str, &ch1); if (ch2 == ch1) { break; } @@ -2195,7 +2195,7 @@ Tcl_StringCaseMatch( if (*str == '\0') { return 0; } - str += Tcl_UtfToUniChar(str, &ch1); + str += TclUtfToUniChar(str, &ch1); } } @@ -2206,7 +2206,7 @@ Tcl_StringCaseMatch( if (p == '?') { pattern++; - str += Tcl_UtfToUniChar(str, &ch1); + str += TclUtfToUniChar(str, &ch1); continue; } @@ -2225,7 +2225,7 @@ Tcl_StringCaseMatch( (nocase ? tolower(UCHAR(*str)) : UCHAR(*str)); str++; } else { - str += Tcl_UtfToUniChar(str, &ch1); + str += TclUtfToUniChar(str, &ch1); if (nocase) { ch1 = Tcl_UniCharToLower(ch1); } @@ -2239,7 +2239,7 @@ Tcl_StringCaseMatch( ? tolower(UCHAR(*pattern)) : UCHAR(*pattern)); pattern++; } else { - pattern += Tcl_UtfToUniChar(pattern, &startChar); + pattern += TclUtfToUniChar(pattern, &startChar); if (nocase) { startChar = Tcl_UniCharToLower(startChar); } @@ -2254,7 +2254,7 @@ Tcl_StringCaseMatch( ? tolower(UCHAR(*pattern)) : UCHAR(*pattern)); pattern++; } else { - pattern += Tcl_UtfToUniChar(pattern, &endChar); + pattern += TclUtfToUniChar(pattern, &endChar); if (nocase) { endChar = Tcl_UniCharToLower(endChar); } @@ -2302,8 +2302,8 @@ Tcl_StringCaseMatch( * each string match. */ - str += Tcl_UtfToUniChar(str, &ch1); - pattern += Tcl_UtfToUniChar(pattern, &ch2); + str += TclUtfToUniChar(str, &ch1); + pattern += TclUtfToUniChar(pattern, &ch2); if (nocase) { if (Tcl_UniCharToLower(ch1) != Tcl_UniCharToLower(ch2)) { return 0; |