From 1418964b105624803cdc3ffb4c939414a0b315f4 Mon Sep 17 00:00:00 2001 From: sebres Date: Sat, 8 Feb 2025 15:49:29 +0000 Subject: simplify and optimize TclSubstOptions (reducing the branch misprediction etc) --- generic/tclCmdMZ.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 06a2786..9293d44 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -3514,8 +3514,8 @@ 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; @@ -3526,19 +3526,7 @@ TclSubstOptions( &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; -- cgit v0.12