diff options
author | Daniel Llorens <lloda@sarc.name> | 2021-08-06 16:51:40 +0200 |
---|---|---|
committer | Daniel Llorens <lloda@sarc.name> | 2021-08-06 17:13:21 +0200 |
commit | 5df5555d12f1408a66a5368a918abb981edf5445 (patch) | |
tree | c6ffa77362fac657c6f77276fadef7efff323611 /module/scheme | |
parent | 091f5062cb2f9f5701b999c3b7ee88a480eeecf7 (diff) | |
download | guile-5df5555d12f1408a66a5368a918abb981edf5445.tar.gz |
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!.
Diffstat (limited to 'module/scheme')
-rw-r--r-- | module/scheme/base.scm | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/module/scheme/base.scm b/module/scheme/base.scm index c57bdf110..c6a73c092 100644 --- a/module/scheme/base.scm +++ b/module/scheme/base.scm @@ -57,7 +57,7 @@ string->vector vector->string (r7:string->utf8 . string->utf8) (r7:vector->list . vector->list) - vector-copy! vector-append vector-for-each vector-map + vector-append vector-for-each vector-map (r7:bytevector-copy . bytevector-copy) (r7:bytevector-copy! . bytevector-copy!) (r7:utf8->string . utf8->string) @@ -114,7 +114,7 @@ (char-ready? . u8-ready?) unless unquote unquote-splicing values - vector vector-copy vector-fill! + vector vector-copy vector-copy! vector-fill! vector-length vector-ref vector-set! vector? when with-exception-handler write-char zero?)) @@ -431,19 +431,6 @@ ;;; vector -(define* (vector-copy! target tstart source - #:optional (sstart 0) (send (vector-length source))) - "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." - (let ((tlen (vector-length target)) - (slen (vector-length source))) - (if (< tstart sstart) - (vector-move-left! source sstart send target tstart) - (vector-move-right! source sstart send target tstart)))) - (define r7:vector->list (case-lambda* ((v) (vector->list v)) |