summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2024-06-12 19:11:29 (GMT)
committersebres <sebres@users.sourceforge.net>2024-06-12 19:11:29 (GMT)
commitc0602af1ad679af5d001d79c58d9811ef9cc476a (patch)
tree0981222e254798c2f532a2a3326f91fc0a34cf0f
parent2fbd19a32f90bb8e5a15d768020565494ba58ff7 (diff)
downloadtcl-c0602af1ad679af5d001d79c58d9811ef9cc476a.zip
tcl-c0602af1ad679af5d001d79c58d9811ef9cc476a.tar.gz
tcl-c0602af1ad679af5d001d79c58d9811ef9cc476a.tar.bz2
speed-up lseq (with expr-args) a bit, as well as avoid shimmer for compiled expressions
-rw-r--r--generic/tclCmdIL.c5
-rw-r--r--generic/tclExecute.c10
-rw-r--r--generic/tclInt.h1
3 files changed, 11 insertions, 5 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index 19bc596..986bd1e 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -4029,6 +4029,10 @@ SequenceIdentifyArgument(
void *internalPtr;
if (allowedArgs & NumericArg) {
+ /* speed-up a bit (and avoid shimmer for compiled expressions) */
+ if (TclHasInternalRep(argPtr, &tclExprCodeType)) {
+ goto doExpr;
+ }
result = Tcl_GetNumberFromObj(NULL, argPtr, &internalPtr, keywordIndexPtr);
if (result == TCL_OK) {
*numValuePtr = argPtr;
@@ -4054,6 +4058,7 @@ SequenceIdentifyArgument(
if (!(allowedArgs & NumericArg)) {
return NoneArg;
}
+ doExpr:
/* Check for an index expression */
int keyword;
if (Tcl_ExprObj(interp, argPtr, &exprValueObj) != TCL_OK) {
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 7ed1a9f..b89853d 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -714,7 +714,7 @@ static Tcl_NRPostProc TEBCresume;
* compiled bytecode for Tcl expressions.
*/
-static const Tcl_ObjType exprCodeType = {
+const Tcl_ObjType tclExprCodeType = {
"exprcode",
FreeExprCodeInternalRep, /* freeIntRepProc */
DupExprCodeInternalRep, /* dupIntRepProc */
@@ -1471,7 +1471,7 @@ CompileExprObj(
* is valid in the current context.
*/
- ByteCodeGetInternalRep(objPtr, &exprCodeType, codePtr);
+ ByteCodeGetInternalRep(objPtr, &tclExprCodeType, codePtr);
if (codePtr != NULL) {
Namespace *namespacePtr = iPtr->varFramePtr->nsPtr;
@@ -1481,7 +1481,7 @@ CompileExprObj(
|| (codePtr->nsPtr != namespacePtr)
|| (codePtr->nsEpoch != namespacePtr->resolverEpoch)
|| (codePtr->localCachePtr != iPtr->varFramePtr->localCachePtr)) {
- Tcl_StoreInternalRep(objPtr, &exprCodeType, NULL);
+ Tcl_StoreInternalRep(objPtr, &tclExprCodeType, NULL);
codePtr = NULL;
}
}
@@ -1514,7 +1514,7 @@ CompileExprObj(
*/
TclEmitOpcode(INST_DONE, &compEnv);
- codePtr = TclInitByteCodeObj(objPtr, &exprCodeType, &compEnv);
+ codePtr = TclInitByteCodeObj(objPtr, &tclExprCodeType, &compEnv);
TclFreeCompileEnv(&compEnv);
if (iPtr->varFramePtr->localCachePtr) {
codePtr->localCachePtr = iPtr->varFramePtr->localCachePtr;
@@ -1583,7 +1583,7 @@ FreeExprCodeInternalRep(
Tcl_Obj *objPtr)
{
ByteCode *codePtr;
- ByteCodeGetInternalRep(objPtr, &exprCodeType, codePtr);
+ ByteCodeGetInternalRep(objPtr, &tclExprCodeType, codePtr);
assert(codePtr != NULL);
TclReleaseByteCode(codePtr);
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 6f06120..1b88332 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -2941,6 +2941,7 @@ MODULE_SCOPE const Tcl_ObjType tclBooleanType;
MODULE_SCOPE const Tcl_ObjType tclByteArrayType;
MODULE_SCOPE const Tcl_ObjType tclByteCodeType;
MODULE_SCOPE const Tcl_ObjType tclDoubleType;
+MODULE_SCOPE const Tcl_ObjType tclExprCodeType;
MODULE_SCOPE const Tcl_ObjType tclIntType;
MODULE_SCOPE const Tcl_ObjType tclIndexType;
MODULE_SCOPE const Tcl_ObjType tclListType;