summaryrefslogtreecommitdiffstats
path: root/generic/tclInt.h
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2014-05-01 07:38:27 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2014-05-01 07:38:27 (GMT)
commit1c52941e5f67f7f374dbc110234bf18a7ac4844a (patch)
tree4f49557b0fc34ae6f65fc299aaadf9d60bfcc691 /generic/tclInt.h
parent7df749abdc0780eb176e6fade94388d60cd8a0ef (diff)
downloadtcl-1c52941e5f67f7f374dbc110234bf18a7ac4844a.zip
tcl-1c52941e5f67f7f374dbc110234bf18a7ac4844a.tar.gz
tcl-1c52941e5f67f7f374dbc110234bf18a7ac4844a.tar.bz2
Fix more corner-cases like [0e92c404f19ede5b2eb06e6db27647d3138cc56|0e92c404f1]: The only place where a type of &tclByteArrayType can be trusted is when determining its length, because the character length of a (UTF-8) string is always equal to the byte length of the byte array.
Diffstat (limited to 'generic/tclInt.h')
-rw-r--r--generic/tclInt.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 00b246b..2353450 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -3668,6 +3668,24 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, CONST char *file,
/*
*----------------------------------------------------------------
+ * 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.
+ * The ANSI C "prototype" for this macro is:
+ *
+ * MODULE_SCOPE int TclIsPureByteArray(Tcl_Obj *objPtr);
+ *----------------------------------------------------------------
+ */
+
+#define TclIsPureByteArray(objPtr) \
+ (((objPtr)->typePtr==&tclByteArrayType) && ((objPtr)->bytes==NULL))
+
+/*
+ *----------------------------------------------------------------
* Macro used by the Tcl core to compare Unicode strings. On big-endian
* systems we can use the more efficient memcmp, but this would not be
* lexically correct on little-endian systems. The ANSI C "prototype" for