Skip to content

Commit

Permalink
merge 8.6 (optimization of TclSubstOptions)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebres committed Feb 8, 2025
2 parents 40db447 + 1418964 commit 89068af
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions generic/tclCmdMZ.c
Original file line number Diff line number Diff line change
Expand Up @@ -3387,31 +3387,19 @@ TclSubstOptions(
static const char *const substOptions[] = {
"-nobackslashes", "-nocommands", "-novariables", NULL
};
enum {
SUBST_NOBACKSLASHES, SUBST_NOCOMMANDS, SUBST_NOVARS
static const int optionFlags[] = {
TCL_SUBST_BACKSLASHES, TCL_SUBST_COMMANDS, TCL_SUBST_VARIABLES
};
int i, flags = TCL_SUBST_ALL;
int flags = TCL_SUBST_ALL;

for (i = 0; i < numOpts; i++) {
for (Tcl_Size i = 0; i < numOpts; i++) {
int optionIndex;

if (Tcl_GetIndexFromObj(interp, opts[i], substOptions, "option", 0,
&optionIndex) != TCL_OK) {
return TCL_ERROR;
}
switch (optionIndex) {
case SUBST_NOBACKSLASHES:
flags &= ~TCL_SUBST_BACKSLASHES;
break;
case SUBST_NOCOMMANDS:
flags &= ~TCL_SUBST_COMMANDS;
break;
case SUBST_NOVARS:
flags &= ~TCL_SUBST_VARIABLES;
break;
default:
Tcl_Panic("Tcl_SubstObjCmd: bad option index to SubstOptions");
}
flags &= ~optionFlags[optionIndex];
}
*flagPtr = flags;
return TCL_OK;
Expand Down

0 comments on commit 89068af

Please sign in to comment.