Raymond Toy pushed to branch issue-240-set-diff-with-hash-table at cmucl / cmucl

Commits:

1 changed file:

Changes:

  • src/code/list.lisp
    ... ... @@ -744,6 +744,8 @@
    744 744
           list
    
    745 745
           (cons item list)))
    
    746 746
     
    
    747
    +(defparameter *min-list-length-for-hashtable*
    
    748
    +  15)
    
    747 749
     
    
    748 750
     ;; Convert a list to a hashtable.  Given 2 lists, find the shorter of
    
    749 751
     ;; the two lists and add the shorter list to a hashtable.  
    
    ... ... @@ -768,7 +770,7 @@
    768 770
                           (return (values length list1)))
    
    769 771
                          ((null l2)
    
    770 772
                           (return (values length list2))))))
    
    771
    -        (when (< len 15)
    
    773
    +        (when (< len *min-list-length-for-hashtable*)
    
    772 774
               (return-from list-to-hashtable (values nil nil)))
    
    773 775
             (cond ((eq shorter-list list2)
    
    774 776
     	       (let ((hashtable (make-hash-table :test test :size len)))
    
    ... ... @@ -869,9 +871,9 @@
    869 871
     	   ;; list2 was placed in hash table.
    
    870 872
     	   (let (diff)
    
    871 873
                  (dolist (item list1)
    
    872
    -	       (unless (gethash (apply-key key item) hashtable)
    
    874
    +	       (unless (nth-value 1 (gethash (apply-key key item) hashtable))
    
    873 875
                      (push item diff)))
    
    874
    -             (nreverse diff)))
    
    876
    +             diff))
    
    875 877
               ((eq shorter-list list1)
    
    876 878
     	   ;; list1 was placed in the hash table.
    
    877 879
                (dolist (item list2)