Changeset 13931


Ignore:
Timestamp:
05/06/12 13:37:33 (11 years ago)
Author:
Mark Evenson
Message:

Fixes #196: STABLE-SORT is only stable for lists.

Somewhat kludgily fix the macrology submitted by Jorge Tavares to pass
all the newly failing ANSI tests introduced. The macrology of
MERGE-VECTORS-BODY and MERGE-SORT-BODY required that the sequences
were of type SIMPLE-VECTOR. But somehow, MERGE-SORT-BODY was not
working when asked to stable sort sequences of type BIT-VECTOR or
STRING, both of which are subtypes of VECTOR but not SIMPLE-VECTOR.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/sort.lisp

    r13873 r13931  
    5252;;; - the merge-vectors algorithm is inspired from the CCL base code
    5353;;;
     54
     55;;; http://trac.common-lisp.net/armedbear/ticket/196
     56;;; TODO Restore the optimization for SIMPLE-VECTOR types by
     57;;; conditionally using aref/svref instead of always using AREF
    5458
    5559(defmacro merge-vectors-body (type ref a start-a end-a b start-b end-b aux start-aux predicate &optional key)
     
    96100         (if (funcall ,predicate ,k-b ,k-a)
    97101       (progn
    98          (setf (svref ,aux ,i-aux) ,v-b
     102;;         (setf (svref ,aux ,i-aux) ,v-b ;; FIXME Ticket #196
     103         (setf (aref ,aux ,i-aux) ,v-b
    99104         ,i-aux (+ ,i-aux 1)
    100105         ,i-b (+ ,i-b 1))
     
    105110               `(,k-b ,v-b))))
    106111       (progn
    107          (setf (svref ,aux ,i-aux) ,v-a
     112;;         (setf (svref ,aux ,i-aux) ,v-a ;; FIXME Ticket #196
     113         (setf (aref ,aux ,i-aux) ,v-a
    108114         ,i-aux (+ ,i-aux 1)
    109115         ,i-a (+ ,i-a 1))
     
    119125               `(,k-a ,v-a))))))))
    120126      (loop
    121         (setf (svref ,aux ,i-aux) ,v-a
     127;;        (setf (svref ,aux ,i-aux) ,v-a ;; FIXME Ticket #196
     128        (setf (aref ,aux ,i-aux) ,v-a
    122129        ,i-a (+ ,i-a 1))
    123130        (when (= ,i-a ,end-a) (return))
     
    157164                ,mid ,end ,aux ,start ,predicate)))))
    158165   (let ((,maux (make-array ,mend)))
    159      (declare (type simple-vector ,maux))
     166;;     (declare (type simple-vector ,maux))
     167     (declare (type vector ,maux))
    160168     (,merge-sort-call ,msequence ,mstart ,mend ,mpredicate ,mkey ,maux nil))))))
    161169
Note: See TracChangeset for help on using the changeset viewer.