Skip to content

Commit 4d462e9

Browse files
committed
Use even terser comparator definitions
1 parent 900ce2d commit 4d462e9

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tools/gbcpal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ double luminance(struct Color color) {
4848
int compare_colors(const void *color1, const void *color2) {
4949
double lum1 = luminance(*(const struct Color *)color1);
5050
double lum2 = luminance(*(const struct Color *)color2);
51-
return lum1 > lum2 ? -1 : lum1 < lum2; // sort lightest to darkest
51+
return (lum1 < lum2) - (lum1 > lum2); // sort lightest to darkest
5252
}
5353

5454
void read_gbcpal(const char *filename, struct Color **colors, size_t *num_colors) {

tools/make_patch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ struct Buffer *process_template(const char *template_filename, const char *patch
417417
int compare_patch(const void *patch1, const void *patch2) {
418418
unsigned int offset1 = ((const struct Patch *)patch1)->offset;
419419
unsigned int offset2 = ((const struct Patch *)patch2)->offset;
420-
return offset1 < offset2 ? -1 : offset1 > offset2;
420+
return (offset1 > offset2) - (offset1 < offset2);
421421
}
422422

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

0 commit comments

Comments
 (0)