summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-12-12 22:16:03 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-12-12 22:16:03 (GMT)
commit593fb1f05420b615597cedfee5793c22b86f32ee (patch)
treecb6def1ab9fed1cf12a71c251ef66c33bd5ae791 /generic
parent72e0f8b3e611e86f8646d36ee861e8d37c27909c (diff)
downloadtk-593fb1f05420b615597cedfee5793c22b86f32ee.zip
tk-593fb1f05420b615597cedfee5793c22b86f32ee.tar.gz
tk-593fb1f05420b615597cedfee5793c22b86f32ee.tar.bz2
Internal optimization in tkImgPhoto.c: Eleminate the need to allocate a temporary 'args' array. Backported from 8.7
Diffstat (limited to 'generic')
-rw-r--r--generic/tkImgPhoto.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index 3d22c63..664d9e0 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -151,8 +151,12 @@ static Tcl_ThreadDataKey dataKey;
*/
static const Tk_ConfigSpec configSpecs[] = {
+ {TK_CONFIG_STRING, "-data", NULL, NULL,
+ NULL, -1, TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_STRING, "-file", NULL, NULL,
NULL, Tk_Offset(PhotoModel, fileString), TK_CONFIG_NULL_OK, NULL},
+ {TK_CONFIG_STRING, "-format", NULL, NULL,
+ NULL, -1, TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_DOUBLE, "-gamma", NULL, NULL,
DEF_PHOTO_GAMMA, Tk_Offset(PhotoModel, gamma), 0, NULL},
{TK_CONFIG_INT, "-height", NULL, NULL,
@@ -1810,33 +1814,29 @@ ImgPhotoConfigureModel(
double oldGamma;
Tcl_Channel chan;
Tk_PhotoImageFormat *imageFormat;
- const char **args;
- args = (const char **)ckalloc((objc + 1) * sizeof(char *));
for (i = 0, j = 0; i < objc; i++,j++) {
- args[j] = Tcl_GetString(objv[i]);
+ const char *arg = Tcl_GetString(objv[i]);
length = objv[i]->length;
- if ((length > 1) && (args[j][0] == '-')) {
- if ((args[j][1] == 'd') &&
- !strncmp(args[j], "-data", length)) {
+ if ((length > 1) && (arg[0] == '-')) {
+ if ((arg[1] == 'd') &&
+ !strncmp(arg, "-data", length)) {
if (++i < objc) {
data = objv[i];
j--;
} else {
- ckfree(args);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"value for \"-data\" missing", -1));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
"MISSING_VALUE", NULL);
return TCL_ERROR;
}
- } else if ((args[j][1] == 'f') &&
- !strncmp(args[j], "-format", length)) {
+ } else if ((arg[1] == 'f') &&
+ !strncmp(arg, "-format", length)) {
if (++i < objc) {
format = objv[i];
j--;
} else {
- ckfree(args);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"value for \"-format\" missing", -1));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
@@ -1875,11 +1875,9 @@ ImgPhotoConfigureModel(
*/
if (Tk_ConfigureWidget(interp, Tk_MainWindow(interp), configSpecs,
- j, args, (char *) modelPtr, flags) != TCL_OK) {
- ckfree(args);
+ objc, (const char **)objv, (char *) modelPtr, flags|TK_CONFIG_OBJS) != TCL_OK) {
goto errorExit;
}
- ckfree(args);
/*
* Regard the empty string for -file, -data or -format as the null value.