From: Stas Boukarev Date: Thu, 8 Dec 2011 14:42:20 +0000 (+0400) Subject: Fix transform for SEARCH on vectors. X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=2c9e9cdf20257c422cd43bd30b89990499bca475;p=sbcl.git Fix transform for SEARCH on vectors. An empty first sequence means that (= start1 end1) and it will match the second sequence anywhere starting from start2, so return start2 in case of (= start1 end1). --- diff --git a/src/compiler/seqtran.lisp b/src/compiler/seqtran.lisp index 9b9db97..f87bd78 100644 --- a/src/compiler/seqtran.lisp +++ b/src/compiler/seqtran.lisp @@ -1087,8 +1087,8 @@ (oops pattern start1 end1)) (unless (<= start2 end2 len2) (oops pattern start2 end2)))) - (when (= 0 end1) - (return-from search 0)) + (when (= end1 start1) + (return-from search start2)) (do (,(if from-end '(index2 (- end2 (- end1 start1)) (1- index2)) '(index2 start2 (1+ index2)))) diff --git a/tests/seq.pure.lisp b/tests/seq.pure.lisp index 3819f41..d6aa497 100644 --- a/tests/seq.pure.lisp +++ b/tests/seq.pure.lisp @@ -290,4 +290,12 @@ (search x #(t t t) :start2 1 :end2 0 :end1 0))) #(t t t)) (sb-kernel:bounding-indices-bad-error () - :ok))))) + :ok)))) + (assert (eql 1 + (funcall (lambda () + (declare (optimize speed)) + (search #() #(1 1) :start2 1 :end2 1))))) + (assert (eql 2 + (funcall (lambda () + (declare (optimize speed)) + (search #(1) #(1 1) :start1 1 :start2 2))))))