fix(area): minor improvements
* fix(area): Correct r_sqrd and dist(int32_t to uint32_t)
since these two variables never become negative
* fix(area): Return early in _lv_area_is_in if pointer outside area
The origin code always does the full check if radius != 0, but it
is unnecessary when is_in equals true.
@@ -239,7 +239,8 @@ bool _lv_area_is_in(const lv_area_t * ain_p, const lv_area_t * aholder_p, lv_coo
is_in = true;
}
- if(radius == 0) return is_in;
+ if (!is_in) return false;
+ if(radius == 0) return true;
/*Check if the corner points are inside the radius or not*/
lv_point_t p;
@@ -398,8 +399,8 @@ static bool lv_point_within_circle(const lv_area_t * area, const lv_point_t * p)
lv_coord_t px = p->x - cx;
lv_coord_t py = p->y - cy;
- int32_t r_sqrd = r * r;
- int32_t dist = (px * px) + (py * py);
+ uint32_t r_sqrd = r * r;
+ uint32_t dist = (px * px) + (py * py);
if(dist <= r_sqrd)
return true;
