summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2024-01-18 14:43:23 +0100
committerEkaitz Zarraga <ekaitz@elenq.tech>2024-01-18 22:48:57 +0100
commit569876ba9503c80c43565d3c9996967f1671c00e (patch)
tree8a652c49c4f79dbe49148bb13955e50d27cbd893
parentf35e8ebd5e8b37d383bf8c08913389facdd7eee0 (diff)
par: piece-table: expose add-buffer-length as a parameter
-rw-r--r--par/piece-table.scm6
-rw-r--r--par/piece-table.sld3
2 files changed, 5 insertions, 4 deletions
diff --git a/par/piece-table.scm b/par/piece-table.scm
index a9c9ef7..948286a 100644
--- a/par/piece-table.scm
+++ b/par/piece-table.scm
@@ -118,16 +118,16 @@
((add-buffer? buffer) (add-buffer-string buffer))
((ro-buffer? buffer) (ro-buffer-string buffer))))
-(define %DEFAULT-ADD-BUFFER-LENGTH 64)
+(define add-buffer-length (make-parameter 100))
(define (make-add-buffer)
- (%make-add-buffer (make-string %DEFAULT-ADD-BUFFER-LENGTH) 0))
+ (%make-add-buffer (make-string (add-buffer-length)) 0))
(define (enlarge-add-buffer! add-buffer at-least)
(let* ((str (add-buffer-string add-buffer))
(len (string-length str))
; TODO: Better algo here?
- (new (make-string (+ len at-least %DEFAULT-ADD-BUFFER-LENGTH))))
+ (new (make-string (+ len at-least (add-buffer-length)))))
(set-add-buffer-string! add-buffer new)
(string-copy! new 0 str)))
diff --git a/par/piece-table.sld b/par/piece-table.sld
index 053b863..420175f 100644
--- a/par/piece-table.sld
+++ b/par/piece-table.sld
@@ -7,5 +7,6 @@
piece-table-insert!
piece-table-delete!
piece-table->string
- string->piece-table)
+ string->piece-table
+ add-buffer-length)
(include "piece-table.scm"))