diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-09-29 04:59:27 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-29 04:59:27 -0700 |
commit | 8b7c9131c1df9a4c92e91499da1046b5b13bd81d (patch) | |
tree | d7b6006808e48c6059590e13c1fde6e3c9dbe900 | |
parent | 3d707aee9ae403bde7ffb69062a29086a7265a5d (diff) | |
download | txr-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.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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); |