From 5dafe038d2ba676341b824c55e3f6bad16411c1a Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Fri, 24 May 2013 02:56:06 +0100 Subject: [PATCH] Remove SLICE --- src/compiler.lisp | 8 -------- src/sequence.lisp | 12 ++++++++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/compiler.lisp b/src/compiler.lisp index 71ba7a1..961315c 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -1446,14 +1446,6 @@ (define-builtin string-upcase (x) (code "make_lisp_string(xstring(" x ").toUpperCase())")) -(define-raw-builtin slice (vector a &optional b) - (js!selfcall - "var vector = " (ls-compile vector) ";" *newline* - "var a = " (ls-compile a) ";" *newline* - "var b;" *newline* - (when b (code "b = " (ls-compile b) ";" *newline*)) - "return vector.slice(a,b);" *newline*)) - (define-raw-builtin funcall (func &rest args) (js!selfcall "var f = " (ls-compile func) ";" *newline* diff --git a/src/sequence.lisp b/src/sequence.lisp index 6ac3ebf..7e96df0 100644 --- a/src/sequence.lisp +++ b/src/sequence.lisp @@ -143,8 +143,12 @@ (rplacd pointer ()) drop-a)))) (copy-list (nthcdr a seq)))) - ((arrayp seq) - (if b - (slice seq a b) - (slice seq a))) + ((vectorp seq) + (let* ((b (or b (length seq))) + (size (- b a)) + (new (make-array size :element-type (array-element-type seq)))) + (do ((i 0 (1+ i)) + (j a (1+ j))) + ((= j b) new) + (aset new i (aref seq j))))) (t (not-seq-error seq)))) -- 1.7.10.4