mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-18 01:30:27 +02:00
Add function vector-copy! to core
This is up to 20%-30% faster than the previous versions in (scheme base) or (srfi srfi-43) that used vector-move-left!/vector-move-right!. * libguile/vectors.h: * libguile/vectors.c: As stated. * doc/ref/api-data.texi (vector-copy!): Document the new function. (vector-fill!): Document optional arguments. (vector-copy): Document optional arguments. * module/scheme/base.scm: Reuse core vector-copy!. * module/srfi/srfi-43.scm: Reuse core vector-copy!.
This commit is contained in:
parent
091f5062cb
commit
5df5555d12
5 changed files with 80 additions and 38 deletions
|
@ -22,7 +22,7 @@
|
|||
#:use-module (srfi srfi-1)
|
||||
#:use-module (srfi srfi-8)
|
||||
#:re-export (make-vector vector vector? vector-ref vector-set!
|
||||
vector-length vector-fill!)
|
||||
vector-length vector-fill! vector-copy!)
|
||||
#:replace (vector-copy list->vector vector->list)
|
||||
#:export (vector-empty? vector= vector-unfold vector-unfold-right
|
||||
vector-reverse-copy
|
||||
|
@ -35,7 +35,7 @@
|
|||
vector-binary-search
|
||||
vector-any vector-every
|
||||
vector-swap! vector-reverse!
|
||||
vector-copy! vector-reverse-copy!
|
||||
vector-reverse-copy!
|
||||
reverse-vector->list
|
||||
reverse-list->vector))
|
||||
|
||||
|
@ -933,19 +933,6 @@ START defaults to 0 and END defaults to the length of VEC."
|
|||
(error-from 'copy! "would write past end of target"))
|
||||
(%copy! target tstart source sstart send)))))))
|
||||
|
||||
(define-vector-copier! vector-copy!
|
||||
"(vector-copy! target tstart source [sstart [send]]) -> unspecified
|
||||
|
||||
Copy a block of elements from SOURCE to TARGET, both of which must be
|
||||
vectors, starting in TARGET at TSTART and starting in SOURCE at
|
||||
SSTART, ending when SEND - SSTART elements have been copied. It is an
|
||||
error for TARGET to have a length less than TSTART + (SEND - SSTART).
|
||||
SSTART defaults to 0 and SEND defaults to the length of SOURCE."
|
||||
(lambda (target tstart source sstart send)
|
||||
(if (< tstart sstart)
|
||||
(vector-move-left! source sstart send target tstart)
|
||||
(vector-move-right! source sstart send target tstart))))
|
||||
|
||||
(define-vector-copier! vector-reverse-copy!
|
||||
"(vector-reverse-copy! target tstart source [sstart [send]]) -> unspecified
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue