Skip to content

Commit

Permalink
Use even terser comparator definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Aug 31, 2024
1 parent 900ce2d commit 4d462e9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/gbcpal.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ double luminance(struct Color color) {
int compare_colors(const void *color1, const void *color2) {
double lum1 = luminance(*(const struct Color *)color1);
double lum2 = luminance(*(const struct Color *)color2);
return lum1 > lum2 ? -1 : lum1 < lum2; // sort lightest to darkest
return (lum1 < lum2) - (lum1 > lum2); // sort lightest to darkest
}

void read_gbcpal(const char *filename, struct Color **colors, size_t *num_colors) {
Expand Down
2 changes: 1 addition & 1 deletion tools/make_patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ struct Buffer *process_template(const char *template_filename, const char *patch
int compare_patch(const void *patch1, const void *patch2) {
unsigned int offset1 = ((const struct Patch *)patch1)->offset;
unsigned int offset2 = ((const struct Patch *)patch2)->offset;
return offset1 < offset2 ? -1 : offset1 > offset2;
return (offset1 > offset2) - (offset1 < offset2);
}

bool verify_completeness(FILE *restrict orig_rom, FILE *restrict new_rom, struct Buffer *patches) {
Expand Down

0 comments on commit 4d462e9

Please sign in to comment.