summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-01-29 20:36:14 -0800
committerKaz Kylheku <kaz@kylheku.com>2025-01-29 20:36:14 -0800
commitd4334dcf457b789520c87a04f1476cc49ce5adaf (patch)
tree0264855a8c28e106ffd696efd7613a70dd81c379
parente068f31a5eb62c12a55f847db5b8ba2b88e36d05 (diff)
downloadtxr-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.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib.c b/lib.c
index 4f5cb11d..99674be5 100644
--- a/lib.c
+++ b/lib.c
@@ -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);