diff options
-rw-r--r-- | par/piece-table.scm | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/par/piece-table.scm b/par/piece-table.scm index 1707e7e..65e733f 100644 --- a/par/piece-table.scm +++ b/par/piece-table.scm @@ -192,6 +192,8 @@ (define (piece-table-for-each piece-table f from to) ;; TODO: default from and to + ;; TODO: maybe combine with the `piece-table-index->piece+index` to find the + ;; `from` "Calls `f` through the characters of the piece-table, like `string-for-each` would do, but the `f` call also includes the piece (to expose extra data) and the index of the character" @@ -236,8 +238,7 @@ (define (piece-table-index->piece+index piece-table pos) "Returns (values piece remainder) or eof-object" - (let loop ((idx 0) - (piece (piece-table-piece piece-table)) + (let loop ((piece (piece-table-piece piece-table)) (rem pos)) (let ((len (piece-length piece))) (cond @@ -247,7 +248,7 @@ ;; TODO: No more pieces, return the end or eof? (error "Requested position out of piece-table")) (else - (loop (+ idx 1) (piece-next piece) (- rem len))))))) + (loop (piece-next piece) (- rem len))))))) (define (piece-table-piece-index piece-table i) (let ((piece-prev/next (if (< i 0) piece-prev piece-next)) |