summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSubodh Kumar <s7158.kumar@samsung.com>2015-03-25 07:00:44 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-03-25 07:00:44 +0900
commit43ead671618b867e8887d35beeec1063bab7ec35 (patch)
treed8b13ea3228885deacac46ee638929c9e28f75dd
parent63e7f8b8a48b3762daba54d180d151932b849504 (diff)
[elm_datetime] Corrected the logic for datetime values comparison.
Summary: Datetime value should be compared earlier to avoid unnecessary code execution. Also added logic for single field comparion which will avoid to compare all fields when field limit is set. Signed Off By: Seongjun Yim <se201.yim@samsung.com> Signed Off By: Hyunseok Yang <hs0219.yang@samsung.com> Signed Off By: Subodh Kumar <s7158.kumar@samsung.com> Test Plan: NA Reviewers: shilpasingh, raster Reviewed By: shilpasingh, raster Subscribers: poornima.srinivasan, govi, rajeshps Differential Revision: https://phab.enlightenment.org/D2202
-rw-r--r--src/lib/elm_datetime.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/lib/elm_datetime.c b/src/lib/elm_datetime.c
index 6948e4570..28f61fa33 100644
--- a/src/lib/elm_datetime.c
+++ b/src/lib/elm_datetime.c
@@ -593,6 +593,20 @@ _date_cmp(struct tm *time1,
593 return EINA_TRUE; 593 return EINA_TRUE;
594} 594}
595 595
596static Eina_Bool
597_field_cmp(Elm_Datetime_Field_Type field_type,
598 struct tm *time1,
599 struct tm *time2)
600{
601 DATETIME_TM_ARRAY(timearr1, time1);
602 DATETIME_TM_ARRAY(timearr2, time2);
603
604 if (*timearr1[field_type] != *timearr2[field_type])
605 return EINA_FALSE;
606 else
607 return EINA_TRUE;
608}
609
596// validates curr_time/min_limt/max_limit according to the newly set value 610// validates curr_time/min_limt/max_limit according to the newly set value
597static void 611static void
598_validate_datetime_limits(struct tm *time1, 612_validate_datetime_limits(struct tm *time1,
@@ -1003,7 +1017,7 @@ _elm_datetime_field_limit_set(Eo *obj, Elm_Datetime_Data *sd, Elm_Datetime_Field
1003 1017
1004 _apply_field_limits(obj); 1018 _apply_field_limits(obj);
1005 1019
1006 if (!_date_cmp(&old_time, &sd->curr_time)) 1020 if (!_field_cmp(fieldtype, &old_time, &sd->curr_time))
1007 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL); 1021 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
1008} 1022}
1009 1023
@@ -1019,11 +1033,9 @@ _elm_datetime_value_get(Eo *obj EINA_UNUSED, Elm_Datetime_Data *sd, struct tm *c
1019EOLIAN static Eina_Bool 1033EOLIAN static Eina_Bool
1020_elm_datetime_value_set(Eo *obj, Elm_Datetime_Data *sd, const struct tm *newtime) 1034_elm_datetime_value_set(Eo *obj, Elm_Datetime_Data *sd, const struct tm *newtime)
1021{ 1035{
1022 struct tm old_time;
1023
1024 EINA_SAFETY_ON_NULL_RETURN_VAL(newtime, EINA_FALSE); 1036 EINA_SAFETY_ON_NULL_RETURN_VAL(newtime, EINA_FALSE);
1025 1037
1026 old_time = sd->curr_time; 1038 if (_date_cmp(&sd->curr_time, newtime)) return EINA_TRUE;
1027 sd->curr_time = *newtime; 1039 sd->curr_time = *newtime;
1028 // apply default field restrictions for curr_time 1040 // apply default field restrictions for curr_time
1029 _apply_range_restrictions(&sd->curr_time); 1041 _apply_range_restrictions(&sd->curr_time);
@@ -1032,8 +1044,7 @@ _elm_datetime_value_set(Eo *obj, Elm_Datetime_Data *sd, const struct tm *newtime
1032 _validate_datetime_limits(&sd->max_limit, &sd->curr_time, EINA_TRUE); 1044 _validate_datetime_limits(&sd->max_limit, &sd->curr_time, EINA_TRUE);
1033 _apply_field_limits(obj); 1045 _apply_field_limits(obj);
1034 1046
1035 if (!_date_cmp(&old_time, &sd->curr_time)) 1047 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
1036 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
1037 1048
1038 return EINA_TRUE; 1049 return EINA_TRUE;
1039} 1050}
@@ -1054,6 +1065,7 @@ _elm_datetime_value_min_set(Eo *obj, Elm_Datetime_Data *sd, const struct tm *min
1054 1065
1055 EINA_SAFETY_ON_NULL_RETURN_VAL(mintime, EINA_FALSE); 1066 EINA_SAFETY_ON_NULL_RETURN_VAL(mintime, EINA_FALSE);
1056 1067
1068 if (_date_cmp(&sd->min_limit, mintime)) return EINA_TRUE;
1057 sd->min_limit = *mintime; 1069 sd->min_limit = *mintime;
1058 old_time = sd->curr_time; 1070 old_time = sd->curr_time;
1059 // apply default field restrictions for min_limit 1071 // apply default field restrictions for min_limit
@@ -1085,6 +1097,7 @@ _elm_datetime_value_max_set(Eo *obj, Elm_Datetime_Data *sd, const struct tm *max
1085 1097
1086 EINA_SAFETY_ON_NULL_RETURN_VAL(maxtime, EINA_FALSE); 1098 EINA_SAFETY_ON_NULL_RETURN_VAL(maxtime, EINA_FALSE);
1087 1099
1100 if (_date_cmp(&sd->max_limit, maxtime)) return EINA_TRUE;
1088 sd->max_limit = *maxtime; 1101 sd->max_limit = *maxtime;
1089 old_time = sd->curr_time; 1102 old_time = sd->curr_time;
1090 // apply default field restrictions for max_limit 1103 // apply default field restrictions for max_limit