summaryrefslogtreecommitdiffstats
path: root/generic/tclClock.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-07-29 00:22:32 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-07-29 00:22:32 (GMT)
commit397413cd716cc73ca6291b8ba67c1c1950624fd2 (patch)
treeb4ef997209cfce2e2a8cd4ff0f0001736d17b9c4 /generic/tclClock.c
parent11fd12af2870dc4cd5c239d7f31f8415ac09b732 (diff)
downloadtcl-397413cd716cc73ca6291b8ba67c1c1950624fd2.zip
tcl-397413cd716cc73ca6291b8ba67c1c1950624fd2.tar.gz
tcl-397413cd716cc73ca6291b8ba67c1c1950624fd2.tar.bz2
[3757cdf808] Refactoring seems to reduce (maybe somewhat kinda sorta) a
bizarre performance regression. Still not what it was. Damn Heisenbugs.
Diffstat (limited to 'generic/tclClock.c')
-rw-r--r--generic/tclClock.c54
1 files changed, 32 insertions, 22 deletions
diff --git a/generic/tclClock.c b/generic/tclClock.c
index 7e917f6..524a9e8 100644
--- a/generic/tclClock.c
+++ b/generic/tclClock.c
@@ -522,6 +522,26 @@ ClockGetdatefieldsObjCmd(
*/
static int
+FetchIntField(
+ Tcl_Interp *interp,
+ Tcl_Obj *dict,
+ Tcl_Obj *key,
+ int *storePtr)
+{
+ Tcl_Obj *value = NULL;
+
+ if (Tcl_DictObjGet(interp, dict, key, &value) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (value == NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "expected key(s) not found in dictionary", -1));
+ return TCL_ERROR;
+ }
+ return TclGetIntFromObj(interp, value, storePtr);
+}
+
+static int
ClockGetjuliandayfromerayearmonthdayObjCmd(
ClientData clientData, /* Opaque pointer to literal pool, etc. */
Tcl_Interp *interp, /* Tcl interpreter */
@@ -551,18 +571,13 @@ ClockGetjuliandayfromerayearmonthdayObjCmd(
|| fieldPtr == NULL
|| Tcl_GetIndexFromObj(interp, fieldPtr, eras, "era", TCL_EXACT,
&era) != TCL_OK
- || Tcl_DictObjGet(interp, dict, literals[LIT_YEAR], &fieldPtr) != TCL_OK
- || fieldPtr == NULL
- || TclGetIntFromObj(interp, fieldPtr, &fields.year) != TCL_OK
- || Tcl_DictObjGet(interp, dict, literals[LIT_MONTH], &fieldPtr) != TCL_OK
- || fieldPtr == NULL
- || TclGetIntFromObj(interp, fieldPtr, &fields.month) != TCL_OK
- || Tcl_DictObjGet(interp, dict, literals[LIT_DAYOFMONTH], &fieldPtr) != TCL_OK
- || fieldPtr == NULL
- || TclGetIntFromObj(interp, fieldPtr, &fields.dayOfMonth)!=TCL_OK
+ || FetchIntField(interp, dict, literals[LIT_YEAR], &fields.year)
+ != TCL_OK
+ || FetchIntField(interp, dict, literals[LIT_MONTH], &fields.month)
+ != TCL_OK
+ || FetchIntField(interp, dict, literals[LIT_DAYOFMONTH],
+ &fields.dayOfMonth) != TCL_OK
|| TclGetIntFromObj(interp, objv[2], &changeover) != TCL_OK) {
- if (fieldPtr == NULL)
- Tcl_SetObjResult(interp, Tcl_NewStringObj("expected key(s) not found in dictionary", -1));
return TCL_ERROR;
}
fields.era = era;
@@ -644,18 +659,13 @@ ClockGetjuliandayfromerayearweekdayObjCmd(
|| fieldPtr == NULL
|| Tcl_GetIndexFromObj(interp, fieldPtr, eras, "era", TCL_EXACT,
&era) != TCL_OK
- || Tcl_DictObjGet(interp, dict, literals[LIT_ISO8601YEAR], &fieldPtr) != TCL_OK
- || fieldPtr == NULL
- || TclGetIntFromObj(interp, fieldPtr, &(fields.iso8601Year)) != TCL_OK
- || Tcl_DictObjGet(interp, dict, literals[LIT_ISO8601WEEK], &fieldPtr) != TCL_OK
- || fieldPtr == NULL
- || TclGetIntFromObj(interp, fieldPtr, &(fields.iso8601Week)) != TCL_OK
- || Tcl_DictObjGet(interp, dict, literals[LIT_DAYOFWEEK], &fieldPtr) != TCL_OK
- || fieldPtr == NULL
- || TclGetIntFromObj(interp, fieldPtr, &(fields.dayOfWeek)) != TCL_OK
+ || FetchIntField(interp, dict, literals[LIT_ISO8601YEAR],
+ &fields.iso8601Year) != TCL_OK
+ || FetchIntField(interp, dict, literals[LIT_ISO8601WEEK],
+ &fields.iso8601Week) != TCL_OK
+ || FetchIntField(interp, dict, literals[LIT_DAYOFWEEK],
+ &fields.dayOfWeek) != TCL_OK
|| TclGetIntFromObj(interp, objv[2], &changeover) != TCL_OK) {
- if (fieldPtr == NULL)
- Tcl_SetObjResult(interp, Tcl_NewStringObj("expected key(s) not found in dictionary", -1));
return TCL_ERROR;
}
fields.era = era;