summaryrefslogtreecommitdiffstats
path: root/generic/tclBinary.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-01-28 21:34:29 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-01-28 21:34:29 (GMT)
commitaf3406f86c40c78cff50cb5003b8be0eae448d54 (patch)
tree8c012550c364d8277f009fec2d98678544ae8d9b /generic/tclBinary.c
parent4247e597c6de977b80205b4c28784465ee05f941 (diff)
downloadtcl-af3406f86c40c78cff50cb5003b8be0eae448d54.zip
tcl-af3406f86c40c78cff50cb5003b8be0eae448d54.tar.gz
tcl-af3406f86c40c78cff50cb5003b8be0eae448d54.tar.bz2
New internal macro TclFetchIntRep, which is faster than Tcl_FetchIntRep.
But ... don't use this function when the result is only compared to NULL: that's just overkill.
Diffstat (limited to 'generic/tclBinary.c')
-rw-r--r--generic/tclBinary.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index acd26bf..f069090 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -291,7 +291,7 @@ int
TclIsPureByteArray(
Tcl_Obj * objPtr)
{
- return (NULL != Tcl_FetchIntRep(objPtr, &properByteArrayType));
+ return objPtr->typePtr == &properByteArrayType;
}
/*
@@ -453,15 +453,15 @@ Tcl_GetByteArrayFromObj(
* array of bytes in the ByteArray object. */
{
ByteArray *baPtr;
- const Tcl_ObjIntRep *irPtr = Tcl_FetchIntRep(objPtr, &properByteArrayType);
+ const Tcl_ObjIntRep *irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
if (irPtr == NULL) {
- irPtr = Tcl_FetchIntRep(objPtr, &tclByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
if (irPtr == NULL) {
SetByteArrayFromAny(NULL, objPtr);
- irPtr = Tcl_FetchIntRep(objPtr, &properByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
if (irPtr == NULL) {
- irPtr = Tcl_FetchIntRep(objPtr, &tclByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
}
}
}
@@ -511,14 +511,14 @@ Tcl_SetByteArrayLength(
Tcl_Panic("%s called with shared object", "Tcl_SetByteArrayLength");
}
- irPtr = Tcl_FetchIntRep(objPtr, &properByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
if (irPtr == NULL) {
- irPtr = Tcl_FetchIntRep(objPtr, &tclByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
if (irPtr == NULL) {
SetByteArrayFromAny(NULL, objPtr);
- irPtr = Tcl_FetchIntRep(objPtr, &properByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
if (irPtr == NULL) {
- irPtr = Tcl_FetchIntRep(objPtr, &tclByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
}
}
}
@@ -562,10 +562,10 @@ SetByteArrayFromAny(
ByteArray *byteArrayPtr;
Tcl_ObjIntRep ir;
- if (Tcl_FetchIntRep(objPtr, &properByteArrayType)) {
+ if (objPtr->typePtr == &properByteArrayType) {
return TCL_OK;
}
- if (Tcl_FetchIntRep(objPtr, &tclByteArrayType)) {
+ if (objPtr->typePtr == &tclByteArrayType) {
return TCL_OK;
}
@@ -611,14 +611,14 @@ static void
FreeByteArrayInternalRep(
Tcl_Obj *objPtr) /* Object with internal rep to free. */
{
- ckfree(GET_BYTEARRAY(Tcl_FetchIntRep(objPtr, &tclByteArrayType)));
+ ckfree(GET_BYTEARRAY(TclFetchIntRep(objPtr, &tclByteArrayType)));
}
static void
FreeProperByteArrayInternalRep(
Tcl_Obj *objPtr) /* Object with internal rep to free. */
{
- ckfree(GET_BYTEARRAY(Tcl_FetchIntRep(objPtr, &properByteArrayType)));
+ ckfree(GET_BYTEARRAY(TclFetchIntRep(objPtr, &properByteArrayType)));
}
/*
@@ -647,7 +647,7 @@ DupByteArrayInternalRep(
ByteArray *srcArrayPtr, *copyArrayPtr;
Tcl_ObjIntRep ir;
- srcArrayPtr = GET_BYTEARRAY(Tcl_FetchIntRep(srcPtr, &tclByteArrayType));
+ srcArrayPtr = GET_BYTEARRAY(TclFetchIntRep(srcPtr, &tclByteArrayType));
length = srcArrayPtr->used;
copyArrayPtr = ckalloc(BYTEARRAY_SIZE(length));
@@ -668,7 +668,7 @@ DupProperByteArrayInternalRep(
ByteArray *srcArrayPtr, *copyArrayPtr;
Tcl_ObjIntRep ir;
- srcArrayPtr = GET_BYTEARRAY(Tcl_FetchIntRep(srcPtr, &properByteArrayType));
+ srcArrayPtr = GET_BYTEARRAY(TclFetchIntRep(srcPtr, &properByteArrayType));
length = srcArrayPtr->used;
copyArrayPtr = ckalloc(BYTEARRAY_SIZE(length));
@@ -702,7 +702,7 @@ UpdateStringOfByteArray(
Tcl_Obj *objPtr) /* ByteArray object whose string rep to
* update. */
{
- const Tcl_ObjIntRep *irPtr = Tcl_FetchIntRep(objPtr, &properByteArrayType);
+ const Tcl_ObjIntRep *irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
ByteArray *byteArrayPtr = GET_BYTEARRAY(irPtr);
unsigned char *src = byteArrayPtr->bytes;
unsigned int i, length = byteArrayPtr->used;
@@ -777,14 +777,14 @@ TclAppendBytesToByteArray(
length = (unsigned int)len;
- irPtr = Tcl_FetchIntRep(objPtr, &properByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
if (irPtr == NULL) {
- irPtr = Tcl_FetchIntRep(objPtr, &tclByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
if (irPtr == NULL) {
SetByteArrayFromAny(NULL, objPtr);
- irPtr = Tcl_FetchIntRep(objPtr, &properByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &properByteArrayType);
if (irPtr == NULL) {
- irPtr = Tcl_FetchIntRep(objPtr, &tclByteArrayType);
+ irPtr = TclFetchIntRep(objPtr, &tclByteArrayType);
}
}
}
@@ -2031,7 +2031,7 @@ FormatNumber(
*/
if (Tcl_GetDoubleFromObj(interp, src, &dvalue) != TCL_OK) {
- const Tcl_ObjIntRep *irPtr = Tcl_FetchIntRep(src, &tclDoubleType);
+ const Tcl_ObjIntRep *irPtr = TclFetchIntRep(src, &tclDoubleType);
if (irPtr == NULL) {
return TCL_ERROR;
}
@@ -2051,7 +2051,7 @@ FormatNumber(
*/
if (Tcl_GetDoubleFromObj(interp, src, &dvalue) != TCL_OK) {
- const Tcl_ObjIntRep *irPtr = Tcl_FetchIntRep(src, &tclDoubleType);
+ const Tcl_ObjIntRep *irPtr = TclFetchIntRep(src, &tclDoubleType);
if (irPtr == NULL) {
return TCL_ERROR;
}