summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyuan Choi <ryuan.choi@gmail.com>2014-02-03 09:03:26 +0900
committerRyuan Choi <ryuan.choi@gmail.com>2014-02-03 09:03:26 +0900
commit5cb9d937e6d5f73bd8dba00fdddbc830ab4192af (patch)
tree01dfe8a0abaf6111302d78671466eeff4ab151b4
parentbadd3df4516c60d4540ce72860177fc16640e269 (diff)
datetime: Refactor to launch test_datetime little bit faster
- Added enabled_filed_count to avoid loop in _elm_datetime_smart_sizing_eval(). sizing_eval is called many times but field_count is only changed when called _reload_format(). - Moved redundant if statement out of the loop in _field_list_display(). - Removed redundant call from _elm_datetime_smart_add(). _field_list_arrange() is called in _reload_format().
-rw-r--r--src/lib/elm_datetime.c29
-rw-r--r--src/lib/elm_widget_datetime.h1
2 files changed, 15 insertions, 15 deletions
diff --git a/src/lib/elm_datetime.c b/src/lib/elm_datetime.c
index bb5ede928..5553b3081 100644
--- a/src/lib/elm_datetime.c
+++ b/src/lib/elm_datetime.c
@@ -103,14 +103,13 @@ _field_list_display(Evas_Object *obj)
103 103
104 ELM_DATETIME_DATA_GET(obj, sd); 104 ELM_DATETIME_DATA_GET(obj, sd);
105 105
106 if (!dt_mod || !dt_mod->field_value_display) return;
107
106 for (idx = 0; idx < ELM_DATETIME_TYPE_COUNT; idx++) 108 for (idx = 0; idx < ELM_DATETIME_TYPE_COUNT; idx++)
107 { 109 {
108 field = sd->field_list + idx; 110 field = sd->field_list + idx;
109 if (field->fmt_exist && field->visible) 111 if (field->fmt_exist && field->visible)
110 { 112 dt_mod->field_value_display(sd->mod_data, field->item_obj);
111 if ((dt_mod) && (dt_mod->field_value_display))
112 dt_mod->field_value_display(sd->mod_data, field->item_obj);
113 }
114 } 113 }
115} 114}
116 115
@@ -326,6 +325,7 @@ _reload_format(Evas_Object *obj)
326 _expand_format(dt_fmt); 325 _expand_format(dt_fmt);
327 326
328 // reset all the fields to disable state 327 // reset all the fields to disable state
328 sd->enabled_field_count = 0;
329 for (idx = 0; idx < ELM_DATETIME_TYPE_COUNT; idx++) 329 for (idx = 0; idx < ELM_DATETIME_TYPE_COUNT; idx++)
330 { 330 {
331 field = sd->field_list + idx; 331 field = sd->field_list + idx;
@@ -336,6 +336,13 @@ _reload_format(Evas_Object *obj)
336 field_count = _parse_format(obj, dt_fmt); 336 field_count = _parse_format(obj, dt_fmt);
337 free(dt_fmt); 337 free(dt_fmt);
338 338
339 for (idx = 0; idx < ELM_DATETIME_TYPE_COUNT; idx++)
340 {
341 field = sd->field_list + idx;
342 if (field->fmt_exist && field->visible)
343 sd->enabled_field_count++;
344 }
345
339 // assign locations to disabled fields for uniform usage 346 // assign locations to disabled fields for uniform usage
340 for (idx = 0; idx < ELM_DATETIME_TYPE_COUNT; idx++) 347 for (idx = 0; idx < ELM_DATETIME_TYPE_COUNT; idx++)
341 { 348 {
@@ -495,20 +502,14 @@ _elm_datetime_smart_disable(Eo *obj, void *_pd, va_list *list)
495static void 502static void
496_elm_datetime_smart_sizing_eval(Eo *obj, void *_pd, va_list *list EINA_UNUSED) 503_elm_datetime_smart_sizing_eval(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
497{ 504{
498 Datetime_Field *field;
499 Evas_Coord minw = -1, minh = -1; 505 Evas_Coord minw = -1, minh = -1;
500 unsigned int idx, field_count = 0;
501 506
502 Elm_Datetime_Smart_Data *sd = _pd; 507 Elm_Datetime_Smart_Data *sd = _pd;
503 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 508 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
504 509
505 for (idx = 0; idx < ELM_DATETIME_TYPE_COUNT; idx++) 510 if (sd->enabled_field_count)
506 { 511 elm_coords_finger_size_adjust(sd->enabled_field_count, &minw, 1, &minh);
507 field = sd->field_list + idx; 512
508 if ((field->visible) && (field->fmt_exist)) field_count++;
509 }
510 if (field_count)
511 elm_coords_finger_size_adjust(field_count, &minw, 1, &minh);
512 edje_object_size_min_restricted_calc 513 edje_object_size_min_restricted_calc
513 (wd->resize_obj, &minw, &minh, minw, minh); 514 (wd->resize_obj, &minw, &minh, minw, minh);
514 evas_object_size_hint_min_set(obj, minw, minh); 515 evas_object_size_hint_min_set(obj, minw, minh);
@@ -836,8 +837,6 @@ _elm_datetime_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
836 _field_list_init(obj); 837 _field_list_init(obj);
837 _reload_format(obj); 838 _reload_format(obj);
838 839
839 _field_list_arrange(obj);
840
841 elm_widget_can_focus_set(obj, EINA_TRUE); 840 elm_widget_can_focus_set(obj, EINA_TRUE);
842 841
843 elm_layout_sizing_eval(obj); 842 elm_layout_sizing_eval(obj);
diff --git a/src/lib/elm_widget_datetime.h b/src/lib/elm_widget_datetime.h
index f49b790b0..58e25ff67 100644
--- a/src/lib/elm_widget_datetime.h
+++ b/src/lib/elm_widget_datetime.h
@@ -61,6 +61,7 @@ struct _Elm_Datetime_Smart_Data
61 Elm_Datetime_Module_Data *mod_data; 61 Elm_Datetime_Module_Data *mod_data;
62 char format[ELM_DATETIME_MAX_FORMAT_LEN]; 62 char format[ELM_DATETIME_MAX_FORMAT_LEN];
63 Evas_Object *access_obj; 63 Evas_Object *access_obj;
64 int enabled_field_count;
64 Eina_Bool user_format : 1; /* whether user set 65 Eina_Bool user_format : 1; /* whether user set
65 * format or default 66 * format or default
66 * format. */ 67 * format. */