summaryrefslogtreecommitdiffstats
path: root/generic/tclUtil.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-11-30 10:36:06 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-11-30 10:36:06 (GMT)
commit5cb9dc5ddc24459e55fab2188d60c867755e6f40 (patch)
tree82d82d4febde81e40c1598d9da74f99869f3ae71 /generic/tclUtil.c
parentc157333a7dd73f35f1c2fe39b186e67ca1051659 (diff)
parentdabfa1a0534f5b346196d940549d2f5bb859c7dd (diff)
downloadtcl-5cb9dc5ddc24459e55fab2188d60c867755e6f40.zip
tcl-5cb9dc5ddc24459e55fab2188d60c867755e6f40.tar.gz
tcl-5cb9dc5ddc24459e55fab2188d60c867755e6f40.tar.bz2
Stop shimmering for "llength". Internal optimization (but using TIP #644)
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r--generic/tclUtil.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 0b898f1..a53ca28 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -122,13 +122,17 @@ static int FindElement(Tcl_Interp *interp, const char *string,
* is unregistered, so has no need of a setFromAnyProc either.
*/
-static const Tcl_ObjType endOffsetType = {
- "end-offset", /* name */
+static size_t LengthOne(TCL_UNUSED(Tcl_Obj *)) {return 1;}
+
+static const TclObjTypeWithAbstractList endOffsetType = {
+ {"end-offset", /* name */
NULL, /* freeIntRepProc */
NULL, /* dupIntRepProc */
NULL, /* updateStringProc */
NULL, /* setFromAnyProc */
- TCL_OBJTYPE_V0
+ TCL_OBJTYPE_V0_1(
+ LengthOne
+ )}
};
/*
@@ -3455,7 +3459,7 @@ GetEndOffsetFromObj(
Tcl_WideInt offset = -1; /* Offset in the "end-offset" expression - 1 */
void *cd;
- while ((irPtr = TclFetchInternalRep(objPtr, &endOffsetType)) == NULL) {
+ while ((irPtr = TclFetchInternalRep(objPtr, &endOffsetType.objType)) == NULL) {
Tcl_ObjInternalRep ir;
size_t length;
const char *bytes = Tcl_GetStringFromObj(objPtr, &length);
@@ -3641,7 +3645,7 @@ GetEndOffsetFromObj(
parseOK:
/* Success. Store the new internal rep. */
ir.wideValue = offset;
- Tcl_StoreInternalRep(objPtr, &endOffsetType, &ir);
+ Tcl_StoreInternalRep(objPtr, &endOffsetType.objType, &ir);
}
offset = irPtr->wideValue;
@@ -3743,7 +3747,7 @@ TclIndexEncode(
int idx;
if (TCL_OK == GetWideForIndex(interp, objPtr, (unsigned)TCL_INDEX_END , &wide)) {
- const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objPtr, &endOffsetType);
+ const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objPtr, &endOffsetType.objType);
if (irPtr && irPtr->wideValue >= 0) {
/* "int[+-]int" syntax, works the same here as "int" */
irPtr = NULL;