summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-29 04:59:27 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-29 04:59:27 -0700
commit8b7c9131c1df9a4c92e91499da1046b5b13bd81d (patch)
treed7b6006808e48c6059590e13c1fde6e3c9dbe900
parent3d707aee9ae403bde7ffb69062a29086a7265a5d (diff)
downloadtxr-8b7c9131c1df9a4c92e91499da1046b5b13bd81d.tar.gz
txr-8b7c9131c1df9a4c92e91499da1046b5b13bd81d.tar.bz2
txr-8b7c9131c1df9a4c92e91499da1046b5b13bd81d.zip
Improve lazy_str_force_upto performance on some cases.
* lib.c (lazy_str_force_upto): Don't allow wastefully small increments; force at least 1024 characters beyond the current length of the prefix.
-rw-r--r--lib.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib.c b/lib.c
index 36849c30..6fd1be06 100644
--- a/lib.c
+++ b/lib.c
@@ -5712,7 +5712,7 @@ val lazy_str_force(val lstr)
val lazy_str_force_upto(val lstr, val index)
{
uses_or2;
- val lim, term, ltrm, len;
+ val lim, term, ltrm, len, effidx = index;
list_collect_decl (strlist, ptail);
type_check(lstr, LSTR);
lim = cdr(lstr->ls.opts);
@@ -5720,7 +5720,13 @@ val lazy_str_force_upto(val lstr, val index)
ltrm = length_str(term);
len = length_str(lstr->ls.prefix);
- while (ge(index, len) && lstr->ls.list &&
+ if (lt(effidx, len))
+ return t;
+
+ if (minus(effidx, len) < num_fast(1024))
+ effidx = plus(len, num_fast(1024));
+
+ while (ge(effidx, len) && lstr->ls.list &&
or2(null(lim),gt(lim,zero)))
{
val next = pop(&lstr->ls.list);