summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2016-10-28 14:06:36 (GMT)
committerdgp <dgp@users.sourceforge.net>2016-10-28 14:06:36 (GMT)
commit93b9034a947791a4a4dbd6a5647939ef5ddc2ae7 (patch)
tree8ccee02c971def1aa3241f42e13bb2606cf6d78e
parent6beda912ab0f8bd8784d7b1a973d3897c89b75c0 (diff)
parent4968966c028c3577f5ef3e604cf1e98b7c37d824 (diff)
downloadtcl-93b9034a947791a4a4dbd6a5647939ef5ddc2ae7.zip
tcl-93b9034a947791a4a4dbd6a5647939ef5ddc2ae7.tar.gz
tcl-93b9034a947791a4a4dbd6a5647939ef5ddc2ae7.tar.bz2
merge trunk
-rw-r--r--generic/tclStringObj.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 1828d20..332990d 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -409,6 +409,15 @@ Tcl_GetCharLength(
int numChars;
/*
+ * Quick, no-shimmer return for short string reps.
+ */
+
+ if ((objPtr->bytes) && (objPtr->length < 2)) {
+ /* 0 bytes -> 0 chars; 1 byte -> 1 char */
+ return objPtr->length;
+ }
+
+ /*
* Optimize the case where we're really dealing with a bytearray object
* without string representation; we don't need to convert to a string to
* perform the get-length operation.