diff options
author | Steve Bennett <steveb@workware.net.au> | 2013-08-02 15:07:23 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2013-08-02 15:23:56 +1000 |
commit | 583ed76d426a42a3e9863933aaabbc0912f60bd7 (patch) | |
tree | 849a5e3ca148e2132864121d04d7e941b7671733 /jim.c | |
parent | 07c5eecc55b7bd3deadaa6d6291323316a5447d6 (diff) | |
download | jimtcl-583ed76d426a42a3e9863933aaabbc0912f60bd7.zip jimtcl-583ed76d426a42a3e9863933aaabbc0912f60bd7.tar.gz jimtcl-583ed76d426a42a3e9863933aaabbc0912f60bd7.tar.bz2 |
Minor code cleanups
Prefer Jim_String() and Jim_Length() over Jim_GetString() where it makes sense.
Use Jim_ListGetIndex() where success is guaranteed.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim.c')
-rw-r--r-- | jim.c | 15 |
1 files changed, 5 insertions, 10 deletions
@@ -5621,13 +5621,7 @@ static void JimSetStackTrace(Jim_Interp *interp, Jim_Obj *stackTraceObj) */ len = Jim_ListLength(interp, interp->stackTrace); if (len >= 3) { - Jim_Obj *filenameObj; - - Jim_ListIndex(interp, interp->stackTrace, len - 2, &filenameObj, JIM_NONE); - - Jim_GetString(filenameObj, &len); - - if (!Jim_Length(filenameObj)) { + if (Jim_Length(Jim_ListGetIndex(interp, interp->stackTrace, len - 2)) == 0) { interp->addStackTrace = 1; } } @@ -5657,10 +5651,11 @@ static void JimAppendStackTrace(Jim_Interp *interp, const char *procname, int len = Jim_ListLength(interp, interp->stackTrace); if (len >= 3) { - Jim_Obj *objPtr; - if (Jim_ListIndex(interp, interp->stackTrace, len - 3, &objPtr, JIM_NONE) == JIM_OK && Jim_Length(objPtr)) { + Jim_Obj *objPtr = Jim_ListGetIndex(interp, interp->stackTrace, len - 3); + if (Jim_Length(objPtr)) { /* Yes, the previous level had procname */ - if (Jim_ListIndex(interp, interp->stackTrace, len - 2, &objPtr, JIM_NONE) == JIM_OK && !Jim_Length(objPtr)) { + objPtr = Jim_ListGetIndex(interp, interp->stackTrace, len - 2); + if (Jim_Length(objPtr) == 0) { /* But no filename, so merge the new info with that frame */ ListSetIndex(interp, interp->stackTrace, len - 2, fileNameObj, 0); ListSetIndex(interp, interp->stackTrace, len - 1, Jim_NewIntObj(interp, linenr), 0); |