about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDaniel Santos <dacs.git@brilhante.top>2022-03-12 17:06:32 +0000
committerDaniel Santos <dacs.git@brilhante.top>2022-03-12 17:06:32 +0000
commit2dd0e8663e0a3eb7d19865206c7764bb71779153 (patch)
tree0cfcd305dd0760443d8b372f84b365159d43c207
parenta1447b807b302e48beeb85a61a1f036db2f5ff77 (diff)
downloadnumericx-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.c8
1 files changed, 7 insertions, 1 deletions
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);