Skip to content

remove abs() from radius #7890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shared-module/vectorio/Circle.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void common_hal_vectorio_circle_set_on_dirty(vectorio_circle_t *self, vectorio_e

uint32_t common_hal_vectorio_circle_get_pixel(void *obj, int16_t x, int16_t y) {
vectorio_circle_t *self = obj;
int16_t radius = abs(self->radius);
int16_t radius = self->radius;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only thing I'd currently advocate for changing in here. This change looks great to me, thanks 😄

You could use the value as-is instead of the typecast it's doing to a signed integer but no big deal either way imo:

Suggested change
int16_t radius = abs(self->radius);
int16_t radius = self->radius;
uint16_t radius = self->radius;

x = abs(x);
y = abs(y);
if (x + y <= radius) {
Expand Down