summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2009-02-25 14:55:43 (GMT)
committerdgp <dgp@users.sourceforge.net>2009-02-25 14:55:43 (GMT)
commit57ca69ee1a85fea74e73766265b67cc85d74081d (patch)
tree5efdf0ade44a52ff2cec1001265f6be0c578e345 /generic
parentd24c35f276199a428012749034360a0ab17c00da (diff)
downloadtcl-57ca69ee1a85fea74e73766265b67cc85d74081d.zip
tcl-57ca69ee1a85fea74e73766265b67cc85d74081d.tar.gz
tcl-57ca69ee1a85fea74e73766265b67cc85d74081d.tar.bz2
* generic/tclCmdMZ.c: Since Tcl_GetCharLength() has its own
* generic/tclExecute.c: optimizations for the tclByteArrayType, stop having the callers do them.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCmdMZ.c9
-rw-r--r--generic/tclExecute.c28
2 files changed, 10 insertions, 27 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 15895c1..5a6f947 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdMZ.c,v 1.179 2009/02/05 22:12:44 dkf Exp $
+ * RCS: @(#) $Id: tclCmdMZ.c,v 1.180 2009/02/25 14:56:05 dgp Exp $
*/
#include "tclInt.h"
@@ -1345,7 +1345,7 @@ StringIndexCmd(
}
/*
- * Get Unicode or byte-array char length to calulate what 'end' means.
+ * Get the char length to calulate what 'end' means.
*/
length = Tcl_GetCharLength(objv[1]);
@@ -2047,9 +2047,8 @@ StringRangeCmd(
}
/*
- * Get the length in actual characters; this uses the unicode string rep
- * or the byte-array rep. We then reduce it by one because 'end' refers to
- * the last character, not one past it.
+ * Get the length in actual characters; Then reduce it by one because
+ * 'end' refers to the last character, not one past it.
*/
length = Tcl_GetCharLength(objv[1]) - 1;
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index ca4312a..e98545e 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclExecute.c,v 1.427 2009/02/14 20:30:13 dgp Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.428 2009/02/25 14:56:07 dgp Exp $
*/
#include "tclInt.h"
@@ -4657,11 +4657,7 @@ TclExecuteByteCode(
valuePtr = OBJ_AT_TOS;
- if (valuePtr->typePtr == &tclByteArrayType) {
- (void) Tcl_GetByteArrayFromObj(valuePtr, &length);
- } else {
- length = Tcl_GetCharLength(valuePtr);
- }
+ length = Tcl_GetCharLength(valuePtr);
TclNewIntObj(objResultPtr, length);
TRACE(("%.20s => %d\n", O2S(valuePtr), length));
NEXT_INST_F(1, 1, 1);
@@ -4681,21 +4677,9 @@ TclExecuteByteCode(
valuePtr = OBJ_UNDER_TOS;
/*
- * If we have a ByteArray object, avoid indexing in the Utf string
- * since the byte array contains one byte per character. Otherwise,
- * use the Unicode string rep to get the index'th char.
+ * Get char length to calulate what 'end' means.
*/
-
- if (valuePtr->typePtr == &tclByteArrayType) {
- bytes = (char *)Tcl_GetByteArrayFromObj(valuePtr, &length);
- } else {
- /*
- * Get Unicode char length to calulate what 'end' means.
- */
-
- length = Tcl_GetCharLength(valuePtr);
- }
-
+ length = Tcl_GetCharLength(valuePtr);
result = TclGetIntForIndexM(interp, value2Ptr, length - 1, &index);
if (result != TCL_OK) {
goto checkForCatch;
@@ -4703,8 +4687,8 @@ TclExecuteByteCode(
if ((index >= 0) && (index < length)) {
if (valuePtr->typePtr == &tclByteArrayType) {
- objResultPtr = Tcl_NewByteArrayObj((unsigned char *)
- (&bytes[index]), 1);
+ objResultPtr = Tcl_NewByteArrayObj(
+ Tcl_GetByteArrayFromObj(valuePtr, &length)+index, 1);
} else if (valuePtr->bytes && length == valuePtr->length) {
objResultPtr = Tcl_NewStringObj((const char *)
(&valuePtr->bytes[index]), 1);