From d488bbe46c920c065b5b2f6a5ef1fc3754df531b Mon Sep 17 00:00:00 2001 From: CLIDragon <84266961+CLIDragon@users.noreply.github.com> Date: Fri, 27 Dec 2024 12:13:44 +1000 Subject: [PATCH] Use .raw() instead of building separately. --- src/point.h | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/point.h b/src/point.h index cdf22f0946d86..3de08fbc7a25a 100644 --- a/src/point.h +++ b/src/point.h @@ -473,31 +473,23 @@ template std::optional find_point_closest_first( const Point ¢er, int min_dist, int max_dist, PredicateFn &&predicate_fn ) { - std::optional n = rectangle_size( min_dist, max_dist ); + const std::optional n = rectangle_size( min_dist, max_dist ); if( n == std::nullopt ) { return {}; } - const bool is_center_included = min_dist == 0; - - if( is_center_included ) { - if( predicate_fn( center ) ) { - return center; - } + if( min_dist == 0 && predicate_fn(center) ) { + return center; } int x_init = std::max( min_dist, 1 ); - point p; - p.x = x_init; - p.y = 1 - x_init; + point p {x_init, 1 - x_init}; - point d; - d.x += 1; + point d { 1, 0 }; for( int i = 0; i < *n; i++ ) { - // FIXME: Ugly but we don't know the type of center + p. - const Point next = Point{ ( center + p ).x, ( center + p ).y, ( center + p ).z }; + const Point next = Point{ center.raw() + p.raw() }; if( predicate_fn( next ) ) { return next; } @@ -507,8 +499,7 @@ std::optional find_point_closest_first( const Point ¢er, int min_dist d.x = -d.x; } - p.x += d.x; - p.y += d.y; + p += d; } return std::nullopt;