diff options
author | dgp <dgp@users.sourceforge.net> | 2017-11-30 17:10:37 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2017-11-30 17:10:37 (GMT) |
commit | 4bbfdee3db6fbfb19e5d19f48bac51280d2e55fa (patch) | |
tree | 272200dafcab248b294fb6b4513f0cafc24b2495 /generic/tclStringObj.c | |
parent | d7d31d6041d72ace8e80d409c12749ab819499ec (diff) | |
download | tcl-4bbfdee3db6fbfb19e5d19f48bac51280d2e55fa.zip tcl-4bbfdee3db6fbfb19e5d19f48bac51280d2e55fa.tar.gz tcl-4bbfdee3db6fbfb19e5d19f48bac51280d2e55fa.tar.bz2 |
[5808081213] Permit all bytearrays (including impure ones) to report length without shimmering
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r-- | generic/tclStringObj.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index d43cc45..0f238cf 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -418,12 +418,16 @@ Tcl_GetCharLength( int numChars; /* - * 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. + * Optimize the case where we're really dealing with a bytearray object; + * we don't need to convert to a string to perform the get-length operation. + * + * NOTE that we do not need the bytearray to be "pure". A ByteArray value + * with a string rep cannot be trusted to represent the same value as the + * string rep, but it *can* be trusted to have the same character length + * as the string rep, which is all this routine cares about. */ - if (TclIsPureByteArray(objPtr)) { + if (objPtr->typePtr == &tclByteArrayType) { int length; (void) Tcl_GetByteArrayFromObj(objPtr, &length); |