perf(obj) remove lv_obj_get_child_cnt from cycle limit checks

This commit is contained in:
Gabor Kiss-Vamosi
2021-07-01 21:49:04 +02:00
parent 90438603ad
commit ebb9ce913e
6 changed files with 27 additions and 14 deletions

View File

@@ -419,7 +419,8 @@ static lv_coord_t find_snap_point_x(const lv_obj_t * obj, lv_coord_t min, lv_coo
lv_coord_t pad_right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN);
uint32_t i;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
for(i = 0; i < child_cnt; i++) {
lv_obj_t * child = lv_obj_get_child(obj, i);
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
if(lv_obj_has_flag(child, LV_OBJ_FLAG_SNAPPABLE)) {
@@ -473,7 +474,8 @@ static lv_coord_t find_snap_point_y(const lv_obj_t * obj, lv_coord_t min, lv_coo
lv_coord_t pad_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN);
uint32_t i;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
for(i = 0; i < child_cnt; i++) {
lv_obj_t * child = lv_obj_get_child(obj, i);
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
if(lv_obj_has_flag(child, LV_OBJ_FLAG_SNAPPABLE)) {

View File

@@ -705,7 +705,8 @@ static void lv_obj_event(const lv_obj_class_t * class_p, lv_event_t * e)
}
uint32_t i;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
for(i = 0; i < child_cnt; i++) {
lv_obj_t * child = lv_obj_get_child(obj, i);
lv_obj_mark_layout_as_dirty(child);
}

View File

@@ -752,7 +752,8 @@ void lv_obj_move_to(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
void lv_obj_move_children_by(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff, bool ignore_floating)
{
uint32_t i;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
for(i = 0; i < child_cnt; i++) {
lv_obj_t * child = lv_obj_get_child(obj, i);
if(ignore_floating && lv_obj_has_flag(child, LV_OBJ_FLAG_FLOATING)) continue;
child->coords.x1 += x_diff;
@@ -934,7 +935,8 @@ static void calc_auto_size(lv_obj_t * obj, lv_coord_t * w_out, lv_coord_t * h_ou
static void layout_update_core(lv_obj_t * obj)
{
uint32_t i;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
for(i = 0; i < child_cnt; i++) {
lv_obj_t * child = lv_obj_get_child(obj, i);
layout_update_core(child);
}

View File

@@ -137,7 +137,8 @@ lv_coord_t lv_obj_get_scroll_bottom(lv_obj_t * obj)
lv_coord_t child_res = LV_COORD_MIN;
uint32_t i;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
for(i = 0; i < child_cnt; i++) {
lv_obj_t * child = lv_obj_get_child(obj, i);
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
child_res = LV_MAX(child_res, child->coords.y2);
@@ -177,7 +178,8 @@ lv_coord_t lv_obj_get_scroll_left(lv_obj_t * obj)
uint32_t i;
lv_coord_t x1 = LV_COORD_MAX;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
for(i = 0; i < child_cnt; i++) {
lv_obj_t * child = lv_obj_get_child(obj, i);
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
x1 = LV_MIN(x1, child->coords.x1);
@@ -212,7 +214,8 @@ lv_coord_t lv_obj_get_scroll_right(lv_obj_t * obj)
/*With other base direction (LTR) scrolling to the right is normal so find the right most coordinate*/
lv_coord_t child_res = LV_COORD_MIN;
uint32_t i;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
for(i = 0; i < child_cnt; i++) {
lv_obj_t * child = lv_obj_get_child(obj, i);
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
child_res = LV_MAX(child_res, child->coords.x2);

View File

@@ -613,7 +613,8 @@ static void report_style_change_core(void * style, lv_obj_t * obj)
}
}
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
for(i = 0; i < child_cnt; i++) {
report_style_change_core(style, lv_obj_get_child(obj, i));
}
}
@@ -626,7 +627,8 @@ static void report_style_change_core(void * style, lv_obj_t * obj)
static void refresh_children_style(lv_obj_t * obj)
{
uint32_t i;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
for(i = 0; i < child_cnt; i++) {
lv_obj_t * child = lv_obj_get_child(obj, i);
lv_obj_invalidate(child);
lv_event_send(child, LV_EVENT_STYLE_CHANGED, NULL);

View File

@@ -184,7 +184,7 @@ void _lv_disp_refr_timer(lv_timer_t * tmr)
TRACE_REFR("begin");
uint32_t start = lv_tick_get();
uint32_t elaps = 0;
volatile uint32_t elaps = 0;
disp_refr = tmr->user_data;
@@ -584,7 +584,8 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj)
if(info.res == LV_COVER_RES_MASKED) return NULL;
uint32_t i;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
for(i = 0; i < child_cnt; i++) {
lv_obj_t * child = lv_obj_get_child(obj, i);
found_p = lv_refr_get_top_obj(area_p, child);
@@ -631,7 +632,8 @@ static void lv_refr_obj_and_children(lv_obj_t * top_p, const lv_area_t * mask_p)
while(par != NULL) {
bool go = false;
uint32_t i;
for(i = 0; i < lv_obj_get_child_cnt(par); i++) {
uint32_t child_cnt = lv_obj_get_child_cnt(par);
for(i = 0; i < child_cnt; i++) {
lv_obj_t * child = lv_obj_get_child(par, i);
if(!go) {
if(child == border_p) go = true;
@@ -703,7 +705,8 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
lv_area_t mask_child; /*Mask from obj and its child*/
lv_area_t child_area;
uint32_t i;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
for(i = 0; i < child_cnt; i++) {
lv_obj_t * child = lv_obj_get_child(obj, i);
lv_obj_get_coords(child, &child_area);
ext_size = _lv_obj_get_ext_draw_size(child);