David Kastrup <d...@gnu.org> writes:

>> (defun delete-dups (list)
>>   "Destructively remove `equal' duplicates from LIST.
>> Store the result in LIST and return it.  LIST must be a proper list.
>> Of several `equal' occurrences of an element in LIST, the first
>> one is kept."
>>   (let ((l (length list)))
>>     (if (> l 100)
>>         (let ((hash (make-hash-table :test #'equal :size l))
>>               (tail list) retail)
>>           (puthash (car list) t hash)
>>           (while (setq retail (cdr tail))
>>             (let ((elt (car retail)))
>>               (if (gethash elt hash)
>>                   (setcdr tail (cdr retail))
>>                 (puthash elt t hash)
>>                 (setq tail retail)))))
>>       (let ((tail list))
>>         (while tail
>>           (setcdr tail (delete (car tail) (cdr tail)))
>>           (setq tail (cdr tail))))))
>>   list)
>
> I'm pretty sure I created an efficient version of delete-dups (didn't
> use a hash table but rather some algorithm based on sorting) for RefTeX
> at one point of time.  Can we use that?
>
> Have I committed it?

Ok, so RefTeX is now in the Emacs repo and it neither defines nor uses
anything called akin to delete-dups.  This is serious "Huh?" domain.
Pretty sure I am not dreaming this up.

At any rate: not sure whether XEmacs has the same
make-hash-table/gethash/puthash calls.

-- 
David Kastrup

_______________________________________________
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel

Reply via email to