seqlib: stable-sort: fix bogus optimization's in #'stable-sort.
authorDaniel Kochmański <dkochmanski@hellsgate.pl>
Tue, 24 Feb 2015 12:30:49 +0000 (13:30 +0100)
committerDaniel Kochmański <dkochmanski@hellsgate.pl>
Tue, 24 Feb 2015 12:36:18 +0000 (13:36 +0100)
This patch fixes bug #292, where #'stable-sort weren't sorting in
place strings, when provided with predicate #'char-greaterp. This was
due to optimization, where if sequence was of type string or
vector-bit function #'sort was called (which invoked #'quicksort),
while for the rest cases merge-sort is used.

Optimization is reduced to use quicksort only on vector-bit sequences.

See: http://sourceforge.net/p/ecls/bugs/292/

src/lsp/seqlib.lsp

index b6e0094..63c58f2 100644 (file)
@@ -882,7 +882,7 @@ SEQUENCE.  See SORT."
        predicate (si::coerce-to-function predicate))
   (if (listp sequence)
       (list-merge-sort sequence predicate key)
-      (if (or (stringp sequence) (bit-vector-p sequence))
+      (if (bit-vector-p sequence)
           (sort sequence predicate :key key)
           (coerce (list-merge-sort (coerce sequence 'list)
                                    predicate