From c17a596a46276be330a0cc30a7c1d4c638847f93 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 7 Sep 2024 17:51:22 +0000 Subject: [PATCH] Use Tk_AllocColorFromObj() in stead of Tk_GetColor() where possible: it's more efficient (see documentation) --- generic/tkCmds.c | 4 ++-- generic/tkImgPhoto.c | 4 ++-- macosx/tkMacOSXDialog.c | 2 +- win/tkWinDialog.c | 2 +- win/tkWinWm.c | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/generic/tkCmds.c b/generic/tkCmds.c index a6421374c..22e489da5 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -1754,11 +1754,11 @@ Tk_WinfoObjCmd( { Colormap temp = Tk_Colormap(tkwin); Tk_Colormap(tkwin) = TK_DYNAMIC_COLORMAP; - colorPtr = Tk_GetColor(interp, tkwin, Tcl_GetString(objv[3])); + colorPtr = Tk_AllocColorFromObj(interp, tkwin, objv[3]); Tk_Colormap(tkwin) = temp; } #else - colorPtr = Tk_GetColor(interp, tkwin, Tcl_GetString(objv[3])); + colorPtr = Tk_AllocColorFromObj(interp, tkwin, objv[3]); #endif if (colorPtr == NULL) { return TCL_ERROR; diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index d1a5f6c52..54e92b3c1 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -1577,8 +1577,8 @@ ParseSubcommandOptions( goto oneValueRequired; } *optIndexPtr = ++index; - optPtr->background = Tk_GetColor(interp, Tk_MainWindow(interp), - Tk_GetUid(Tcl_GetString(objv[index]))); + optPtr->background = Tk_AllocColorFromObj(interp, Tk_MainWindow(interp), + objv[index]); if (!optPtr->background) { return TCL_ERROR; } diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index a6d3c4476..8b53f97af 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -462,7 +462,7 @@ Tk_ChooseColorObjCmd( case COLOR_INITIAL: { XColor *colorPtr; - colorPtr = Tk_GetColor(interp, tkwin, value); + colorPtr = Tk_AllocColorFromObj(interp, tkwin, objv[i + 1]); if (colorPtr == NULL) { goto end; } diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index fca6cf114..e2cc7734f 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -816,7 +816,7 @@ Tk_ChooseColorObjCmd( case COLOR_INITIAL: { XColor *colorPtr; - colorPtr = Tk_GetColor(interp, tkwin, string); + colorPtr = Tk_AllocColorFromObj(interp, tkwin, valuePtr); if (colorPtr == NULL) { return TCL_ERROR; } diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 60554c4e3..b0459d459 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -3137,7 +3137,7 @@ WmAttributesCmd( } wmPtr->alpha = dval; } else { /* -transparentcolor */ - const char *crefstr = Tcl_GetStringFromObj(objv[i+1], &length); + (void)Tcl_GetStringFromObj(objv[i+1], &length); if (length == 0) { /* reset to no transparent color */ @@ -3147,7 +3147,7 @@ WmAttributesCmd( } } else { XColor *cPtr = - Tk_GetColor(interp, tkwin, Tk_GetUid(crefstr)); + Tk_AllocColorFromObj(interp, tkwin, objv[i+1]); if (cPtr == NULL) { return TCL_ERROR; }