From 2dd0e8663e0a3eb7d19865206c7764bb71779153 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Sat, 12 Mar 2022 17:06:32 +0000 Subject: minor optimization for main cycle * optimizes main counting cycle if TO_INFINITE_BASE is set, by adding to_second variable Signed-off-by: Daniel Santos --- numericx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/numericx.c b/numericx.c index b8c0254..287b6d0 100644 --- a/numericx.c +++ b/numericx.c @@ -280,6 +280,12 @@ main(int argc, char* argv[]) increment(result, to_first, to_last, to_first); } + /* minor optimization for the cycle below */ + char* to_second = NULL; + + if( TO_INFINITE_BASE ) + to_second = to_first + 1; + /* increments until it finishes */ while( !is_the_same(counting, number) ) { @@ -287,7 +293,7 @@ main(int argc, char* argv[]) print_numeral(result); if( TO_INFINITE_BASE ) - increment(result, to_first, to_last, (to_first + 1)); + increment(result, to_first, to_last, to_second); else increment(result, to_first, to_last, to_first); -- cgit