summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-11-15 06:12:58 -0800
committerKaz Kylheku <kaz@kylheku.com>2017-11-15 06:12:58 -0800
commit6f7c75ed060f3c824740cf0a471be4a235f2fe51 (patch)
tree0f4fbcdf306d85668b2152fcbe998471b95059f2
parentb19f145f88e9fd62c8d6e99cb8470563c9997234 (diff)
downloadtxr-6f7c75ed060f3c824740cf0a471be4a235f2fe51.tar.gz
txr-6f7c75ed060f3c824740cf0a471be4a235f2fe51.tar.bz2
txr-6f7c75ed060f3c824740cf0a471be4a235f2fe51.zip
find-max: tiny optimization for vectors.
* lib.c (find_max): The vector case must loop from index one, not zero, so as not to wastefully compare the initial max element to itself.
-rw-r--r--lib.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index 41489315..ab6e3beb 100644
--- a/lib.c
+++ b/lib.c
@@ -8572,7 +8572,7 @@ val find_max(val seq, val testfun, val keyfun)
val len = length(vec);
val i;
- for (i = zero; lt(i, len); i = succ(i)) {
+ for (i = one; lt(i, len); i = succ(i)) {
val elt = ref(vec, i);
val key = funcall1(keyfun, elt);
if (funcall2(testfun, key, maxkey)) {