summaryrefslogtreecommitdiffstats
path: root/generic/tclStringObj.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2003-02-15 02:14:33 (GMT)
committerhobbs <hobbs>2003-02-15 02:14:33 (GMT)
commit4c59a759acddf715924ba214569ef07d0e78cb05 (patch)
tree8318aab7daec160c44b4e65febf1acea3146ad64 /generic/tclStringObj.c
parentd50d704fc8bf86408b9e2f23add29011da4cce8c (diff)
downloadtcl-4c59a759acddf715924ba214569ef07d0e78cb05.zip
tcl-4c59a759acddf715924ba214569ef07d0e78cb05.tar.gz
tcl-4c59a759acddf715924ba214569ef07d0e78cb05.tar.bz2
generic/tclStringObj.c (Tcl_GetCharLength): perf tweak
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r--generic/tclStringObj.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 41ecf137..e724e9b 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -33,7 +33,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclStringObj.c,v 1.29 2003/02/11 18:35:11 hobbs Exp $ */
+ * RCS: @(#) $Id: tclStringObj.c,v 1.30 2003/02/15 02:14:33 hobbs Exp $ */
#include "tclInt.h"
@@ -376,7 +376,7 @@ Tcl_GetCharLength(objPtr)
*/
if (stringPtr->numChars == -1) {
- register int i = 0, len = objPtr->length;
+ register int i = objPtr->length;
register unsigned char *str = (unsigned char *) objPtr->bytes;
/*
@@ -386,13 +386,14 @@ Tcl_GetCharLength(objPtr)
stringPtr->numChars = Tcl_NumUtfChars(objPtr->bytes, objPtr->length);
*/
- while ((i < len) && (*str < 0xC0)) { i++; str++; }
- stringPtr->numChars = i;
- if (i < len) {
- stringPtr->numChars += Tcl_NumUtfChars(objPtr->bytes + i, len - i);
+ while (i && (*str < 0xC0)) { i--; str++; }
+ stringPtr->numChars = objPtr->length - i;
+ if (i) {
+ stringPtr->numChars += Tcl_NumUtfChars(objPtr->bytes
+ + (objPtr->length - i), i);
}
- if (stringPtr->numChars == len) {
+ if (stringPtr->numChars == objPtr->length) {
/*
* Since we've just calculated the number of chars, and all