Skip to content

Commit

Permalink
buffer: rewrite flexvector grow! implementation using vector-resize
Browse files Browse the repository at this point in the history
The vector-resize procedure is a CHICKEN extension, under the hood
it pretty much does the same as the prior code.
  • Loading branch information
nmeum committed Aug 10, 2024
1 parent 4d45e3b commit ea25fcc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/buffer.sld
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

(srfi 1)

(only (chicken base) vector-resize)

(edward util))

(export make-buffer buffer->list buffer-length buffer-empty?
Expand Down
5 changes: 3 additions & 2 deletions lib/buffer/srfi214-minimal.scm
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@

(define (grow! fv)
(define old-vec (vec fv))
(define new-vec (make-vector (quotient (* (vector-length old-vec) 3) 2)))
(vector-copy! new-vec 0 old-vec)
(define
new-vec
(vector-resize old-vec (quotient (* (vector-length old-vec) 3) 2)))
(set-vec! fv new-vec)
new-vec)

Expand Down

0 comments on commit ea25fcc

Please sign in to comment.