mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-30 01:48:15 +03:00
Remove VVV_min/max in favor of SDL_min/max
VVV_min/max are functions that only operate on ints, and SDL_min/max are macros that operate on any type but double-evaluate everything. I know I more-or-less said earlier that SDL_min/max were dumb but I've changed my mind and think it's better to use them, taking care to make sure you don't double-evaluate, rather than trying to generate your own litany of functions with either your own hand-rolled generation macros, C++ templates, C11 generics, or GCC extensions (that last one you'd technically use in a macro but it doesn't really matter), all of which have more downsides than just not double-evaluating. And the upside of not double-evaluating is that you're disencouraged from having really complicated single-line min/max expressions and encouraged to precompute the values beforehand anyway so the final min/max is more readable. And furthermore you'll notice when you yourself end up doing double-evaluations anyway. I removed a couple instances of Graphics::len() being double-evaluated in this commit (as well as cleaned up some other min/max-using code). Although the only downside to those double-evaluations was unnecessary computation, rather than checking the wrong result or having multiple side effects, thankfully, it's still good to minimize double-evaluations where possible.
This commit is contained in:
@@ -451,7 +451,7 @@ static void menurender(void)
|
||||
graphics.Print( 40, 30, "the following patrons", tr, tg, tb, true);
|
||||
|
||||
int startidx = game.current_credits_list_index;
|
||||
int endidx = VVV_min(startidx + 9, (int)SDL_arraysize(Credits::superpatrons));
|
||||
int endidx = SDL_min(startidx + 9, (int)SDL_arraysize(Credits::superpatrons));
|
||||
|
||||
int xofs = 80 - 16;
|
||||
int yofs = 40 + 20;
|
||||
@@ -469,7 +469,7 @@ static void menurender(void)
|
||||
graphics.Print( -1, 20, "and also by", tr, tg, tb, true);
|
||||
|
||||
int startidx = game.current_credits_list_index;
|
||||
int endidx = VVV_min(startidx + 14, (int)SDL_arraysize(Credits::patrons));
|
||||
int endidx = SDL_min(startidx + 14, (int)SDL_arraysize(Credits::patrons));
|
||||
|
||||
int maxheight = 10 * 14;
|
||||
int totalheight = (endidx - startidx) * 10;
|
||||
@@ -490,7 +490,7 @@ static void menurender(void)
|
||||
graphics.Print( 40, 30, "GitHub from", tr, tg, tb, true);
|
||||
|
||||
int startidx = game.current_credits_list_index;
|
||||
int endidx = VVV_min(startidx + 9, (int)SDL_arraysize(Credits::githubfriends));
|
||||
int endidx = SDL_min(startidx + 9, (int)SDL_arraysize(Credits::githubfriends));
|
||||
|
||||
int maxheight = 14 * 9;
|
||||
int totalheight = (endidx - startidx) * 14;
|
||||
|
||||
Reference in New Issue
Block a user