diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2009-07-12 18:04:33 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2009-07-12 18:04:33 (GMT) |
commit | 02457f7d6507f76fac8b308899e6592ab8214cb3 (patch) | |
tree | 84e622e144e045fb36d18b1ef70c6561ee1a920f /generic/tclStringObj.c | |
parent | fde10a8fbff3c774f95f668f51b6d60c1489d50d (diff) | |
download | tcl-02457f7d6507f76fac8b308899e6592ab8214cb3.zip tcl-02457f7d6507f76fac8b308899e6592ab8214cb3.tar.gz tcl-02457f7d6507f76fac8b308899e6592ab8214cb3.tar.bz2 |
Fix [Bug 2637173] by consolidating bytearray purity check.
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r-- | generic/tclStringObj.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 09ac25a..7804e1f 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.126 2009/07/01 15:06:06 patthoyts Exp $ */ + * RCS: @(#) $Id: tclStringObj.c,v 1.127 2009/07/12 18:04:33 dkf Exp $ */ #include "tclInt.h" #include "tommath.h" @@ -144,19 +144,6 @@ typedef struct String { ((objPtr)->internalRep.otherValuePtr = (void *) (stringPtr)) /* - * Macro that encapsulates the logic that determines when it is safe to - * interpret a string as a byte array directly. In summary, the object must be - * a byte array and must not have a string representation (as the operations - * that it is used in are defined on strings, not byte arrays). Theoretically - * it is possible to also be efficient in the case where the object's bytes - * field is filled by generation from the byte array (c.f. list canonicality) - * but we don't do that at the moment since this is purely about efficiency. - */ - -#define IS_PURE_BYTE_ARRAY(objPtr) \ - (((objPtr)->typePtr==&tclByteArrayType) && ((objPtr)->bytes==NULL)) - -/* * TCL STRING GROWTH ALGORITHM * * When growing strings (during an append, for example), the following growth @@ -472,7 +459,7 @@ Tcl_GetCharLength( * perform the get-length operation. */ - if (IS_PURE_BYTE_ARRAY(objPtr)) { + if (TclIsPureByteArray(objPtr)) { int length; (void) Tcl_GetByteArrayFromObj(objPtr, &length); @@ -538,7 +525,7 @@ Tcl_GetUniChar( * perform the indexing operation. */ - if (IS_PURE_BYTE_ARRAY(objPtr)) { + if (TclIsPureByteArray(objPtr)) { unsigned char *bytes = Tcl_GetByteArrayFromObj(objPtr, NULL); return (Tcl_UniChar) bytes[index]; @@ -669,7 +656,7 @@ Tcl_GetRange( * perform the substring operation. */ - if (IS_PURE_BYTE_ARRAY(objPtr)) { + if (TclIsPureByteArray(objPtr)) { unsigned char *bytes = Tcl_GetByteArrayFromObj(objPtr, NULL); return Tcl_NewByteArrayObj(bytes+first, last-first+1); @@ -1247,7 +1234,7 @@ Tcl_AppendObjToObj( * information; this is a special-case optimization only. */ - if (IS_PURE_BYTE_ARRAY(objPtr) && IS_PURE_BYTE_ARRAY(appendObjPtr)) { + if (TclIsPureByteArray(objPtr) && TclIsPureByteArray(appendObjPtr)) { unsigned char *bytesDst, *bytesSrc; int lengthSrc, lengthTotal; |