diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2025-01-29 20:36:14 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2025-01-29 20:36:14 -0800 |
commit | d4334dcf457b789520c87a04f1476cc49ce5adaf (patch) | |
tree | 0264855a8c28e106ffd696efd7613a70dd81c379 | |
parent | e068f31a5eb62c12a55f847db5b8ba2b88e36d05 (diff) | |
download | txr-d4334dcf457b789520c87a04f1476cc49ce5adaf.tar.gz txr-d4334dcf457b789520c87a04f1476cc49ce5adaf.tar.bz2 txr-d4334dcf457b789520c87a04f1476cc49ce5adaf.zip |
string-extend: grow faster.
* lib.c (string_extend): When more space is needed in the
string, grow by 50% rather than 25%. This speeds up code
at the expense of some wasted space. Waste space can be
dealt with by the final flag in programs where it matters.
-rw-r--r-- | lib.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -5416,10 +5416,10 @@ val string_extend(val str, val tail, val finish_in) if (needed > alloc || finish) { if (finish) alloc = needed; - else if (alloc >= (NUM_MAX - NUM_MAX / 5)) + else if (alloc >= (NUM_MAX - NUM_MAX / 3)) alloc = NUM_MAX; else - alloc = max(alloc + alloc / 4, needed); + alloc = max(alloc + alloc / 2, needed); if (alloc != oalloc) { str->st.str = chk_wrealloc(str->st.str, alloc); |