diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-02-12 20:32:05 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-02-12 20:32:05 (GMT) |
commit | f14346f41e7d066d72062435f39c621fd7b026c1 (patch) | |
tree | f0dd3d34c50b214137f26c296ab39127fc2fe032 /generic | |
parent | 6f7b389dd93395bc77e91a3bb5680aedf5d61a4c (diff) | |
download | tk-f14346f41e7d066d72062435f39c621fd7b026c1.zip tk-f14346f41e7d066d72062435f39c621fd7b026c1.tar.gz tk-f14346f41e7d066d72062435f39c621fd7b026c1.tar.bz2 |
Use (more efficient) Tcl_GetIntFromObj() in stead of Tcl_GetInt() in a few places where it makes sense.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkEntry.c | 59 | ||||
-rw-r--r-- | generic/tkMenu.c | 2 | ||||
-rw-r--r-- | generic/ttk/ttkEntry.c | 2 |
3 files changed, 31 insertions, 32 deletions
diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 5dff50e..00c6fc4 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -426,7 +426,7 @@ static int EntryWidgetObjCmd(ClientData clientData, Tcl_Obj *const objv[]); static void EntryWorldChanged(ClientData instanceData); static int GetEntryIndex(Tcl_Interp *interp, Entry *entryPtr, - const char *string, int *indexPtr); + Tcl_Obj *indexObj, int *indexPtr); static int InsertChars(Entry *entryPtr, int index, const char *string); /* @@ -618,7 +618,7 @@ EntryWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "index"); goto error; } - if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + if (GetEntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) { goto error; } @@ -670,13 +670,13 @@ EntryWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "firstIndex ?lastIndex?"); goto error; } - if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + if (GetEntryIndex(interp, entryPtr, objv[2], &first) != TCL_OK) { goto error; } if (objc == 3) { last = first + 1; - } else if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[3]), + } else if (GetEntryIndex(interp, entryPtr, objv[3], &last) != TCL_OK) { goto error; } @@ -702,7 +702,7 @@ EntryWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "pos"); goto error; } - if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + if (GetEntryIndex(interp, entryPtr, objv[2], &entryPtr->insertPos) != TCL_OK) { goto error; } @@ -716,7 +716,7 @@ EntryWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "string"); goto error; } - if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + if (GetEntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) { goto error; } @@ -731,7 +731,7 @@ EntryWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "index text"); goto error; } - if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + if (GetEntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) { goto error; } @@ -811,7 +811,7 @@ EntryWidgetObjCmd( goto error; } if (GetEntryIndex(interp, entryPtr, - Tcl_GetString(objv[3]), &index) != TCL_OK) { + objv[3], &index) != TCL_OK) { goto error; } if (entryPtr->selectFirst >= 0) { @@ -851,7 +851,7 @@ EntryWidgetObjCmd( goto error; } if (GetEntryIndex(interp, entryPtr, - Tcl_GetString(objv[3]), &index) != TCL_OK) { + objv[3], &index) != TCL_OK) { goto error; } entryPtr->selectAnchor = index; @@ -871,11 +871,11 @@ EntryWidgetObjCmd( Tcl_WrongNumArgs(interp, 3, objv, "start end"); goto error; } - if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[3]), + if (GetEntryIndex(interp, entryPtr, objv[3], &index) != TCL_OK) { goto error; } - if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[4]), + if (GetEntryIndex(interp, entryPtr, objv[4], &index2) != TCL_OK) { goto error; } @@ -902,7 +902,7 @@ EntryWidgetObjCmd( goto error; } if (GetEntryIndex(interp, entryPtr, - Tcl_GetString(objv[3]), &index) != TCL_OK) { + objv[3], &index) != TCL_OK) { goto error; } EntrySelectTo(entryPtr, index); @@ -942,7 +942,7 @@ EntryWidgetObjCmd( Tcl_SetObjResult(interp, Tcl_NewListObj(2, span)); goto done; } else if (objc == 3) { - if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + if (GetEntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) { goto error; } @@ -2556,12 +2556,11 @@ GetEntryIndex( Tcl_Interp *interp, /* For error messages. */ Entry *entryPtr, /* Entry for which the index is being * specified. */ - const char *string, /* Specifies character in entryPtr. */ + Tcl_Obj *indexObj, /* Specifies character in entryPtr. */ int *indexPtr) /* Where to store converted character index */ { - size_t length; - - length = strlen(string); + const char *string = Tcl_GetString(indexObj); + size_t length = indexObj->length; switch (string[0]) { case 'a': @@ -2636,7 +2635,7 @@ GetEntryIndex( break; } default: - if (Tcl_GetInt(NULL, string, indexPtr) != TCL_OK) { + if (Tcl_GetIntFromObj(NULL, indexObj, indexPtr) != TCL_OK) { goto badIndex; } if (*indexPtr < 0){ @@ -3749,7 +3748,7 @@ SpinboxWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "index"); goto error; } - if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + if (GetEntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) { goto error; } @@ -3800,14 +3799,14 @@ SpinboxWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "firstIndex ?lastIndex?"); goto error; } - if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + if (GetEntryIndex(interp, entryPtr, objv[2], &first) != TCL_OK) { goto error; } if (objc == 3) { last = first + 1; } else { - if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[3]), + if (GetEntryIndex(interp, entryPtr, objv[3], &last) != TCL_OK) { goto error; } @@ -3834,7 +3833,7 @@ SpinboxWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "pos"); goto error; } - if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + if (GetEntryIndex(interp, entryPtr, objv[2], &entryPtr->insertPos) != TCL_OK) { goto error; } @@ -3867,7 +3866,7 @@ SpinboxWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "string"); goto error; } - if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + if (GetEntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) { goto error; } @@ -3882,7 +3881,7 @@ SpinboxWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "index text"); goto error; } - if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + if (GetEntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) { goto error; } @@ -3979,7 +3978,7 @@ SpinboxWidgetObjCmd( goto error; } if (GetEntryIndex(interp, entryPtr, - Tcl_GetString(objv[3]), &index) != TCL_OK) { + objv[3], &index) != TCL_OK) { goto error; } if (entryPtr->selectFirst >= 0) { @@ -4019,7 +4018,7 @@ SpinboxWidgetObjCmd( goto error; } if (GetEntryIndex(interp, entryPtr, - Tcl_GetString(objv[3]), &index) != TCL_OK) { + objv[3], &index) != TCL_OK) { goto error; } entryPtr->selectAnchor = index; @@ -4040,11 +4039,11 @@ SpinboxWidgetObjCmd( goto error; } if (GetEntryIndex(interp, entryPtr, - Tcl_GetString(objv[3]), &index) != TCL_OK) { + objv[3], &index) != TCL_OK) { goto error; } if (GetEntryIndex(interp, entryPtr, - Tcl_GetString(objv[4]),& index2) != TCL_OK) { + objv[4],& index2) != TCL_OK) { goto error; } if (index >= index2) { @@ -4070,7 +4069,7 @@ SpinboxWidgetObjCmd( goto error; } if (GetEntryIndex(interp, entryPtr, - Tcl_GetString(objv[3]), &index) != TCL_OK) { + objv[3], &index) != TCL_OK) { goto error; } EntrySelectTo(entryPtr, index); @@ -4150,7 +4149,7 @@ SpinboxWidgetObjCmd( Tcl_SetObjResult(interp, Tcl_NewListObj(2, span)); goto done; } else if (objc == 3) { - if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + if (GetEntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) { goto error; } diff --git a/generic/tkMenu.c b/generic/tkMenu.c index d51febb..318930f 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -2144,7 +2144,7 @@ TkGetMenuIndex( } if (isdigit(UCHAR(string[0]))) { - if (Tcl_GetInt(interp, string, &i) == TCL_OK) { + if (Tcl_GetIntFromObj(interp, objPtr, &i) == TCL_OK) { if (i >= menuPtr->numEntries) { if (lastOK) { i = menuPtr->numEntries; diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index 352c53a..44e45de 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -1382,7 +1382,7 @@ EntryIndex( *indexPtr += 1; } } else { - if (Tcl_GetInt(interp, string, indexPtr) != TCL_OK) { + if (Tcl_GetIntFromObj(interp, indexObj, indexPtr) != TCL_OK) { goto badIndex; } if (*indexPtr < 0) { |