diff options
| author | Daniel Santos <dacs.git@brilhante.top> | 2022-03-12 17:06:32 +0000 |
|---|---|---|
| committer | Daniel Santos <dacs.git@brilhante.top> | 2022-03-12 17:06:32 +0000 |
| commit | 2dd0e8663e0a3eb7d19865206c7764bb71779153 (patch) | |
| tree | 0cfcd305dd0760443d8b372f84b365159d43c207 | |
| parent | a1447b807b302e48beeb85a61a1f036db2f5ff77 (diff) | |
| download | numericx-c-2dd0e8663e0a3eb7d19865206c7764bb71779153.tar.gz | |
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 <dacs.git@brilhante.top>
| -rw-r--r-- | numericx.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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); |