From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Artur Malabarba Newsgroups: gmane.emacs.devel Subject: Re: What to do for faster `remove-duplicates'? Date: Wed, 6 May 2015 19:33:07 +0100 Message-ID: References: <87383atb2p.fsf@gmail.com> <873839ltoa.fsf@gmail.com> <87bnhxeh4j.fsf@gmail.com> Reply-To: bruce.connor.am@gmail.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1430937196 17724 80.91.229.3 (6 May 2015 18:33:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 6 May 2015 18:33:16 +0000 (UTC) Cc: emacs-devel To: Thierry Volpiatto Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 06 20:33:14 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Yq489-0001A0-FU for ged-emacs-devel@m.gmane.org; Wed, 06 May 2015 20:33:13 +0200 Original-Received: from localhost ([::1]:46701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yq488-00066q-Ob for ged-emacs-devel@m.gmane.org; Wed, 06 May 2015 14:33:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yq485-00066l-BL for emacs-devel@gnu.org; Wed, 06 May 2015 14:33:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yq484-0003oO-FW for emacs-devel@gnu.org; Wed, 06 May 2015 14:33:09 -0400 Original-Received: from mail-la0-x22c.google.com ([2a00:1450:4010:c03::22c]:34285) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yq484-0003oC-8F for emacs-devel@gnu.org; Wed, 06 May 2015 14:33:08 -0400 Original-Received: by laat2 with SMTP id t2so13970114laa.1 for ; Wed, 06 May 2015 11:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=tczjvzLyq/ttkM/fIYmFm43ZJK830B8FQ7mpBfWQgLo=; b=yHEv4ye7v0Q1rVN+YSbeJZ5HMNdY8zPIX23Ysviczss1HYGo1e0a1p9xnSs++d4swK FzUk6+dMVLeFH85/4ZmJy30nWhAwgjL1isv8r9/SdFt6rBovZQhxeIGf4bPreTldB+Ue 9iAlUd10q+uvYZJ7lkmmJHD0R8EcVxcP08r1NI3WxMr67ld//5ZJkIEv0zpBuvsuf1jA z2qsH3hCQCK0m2Qtn6KEWQThHxki75WMxmTffJ7v3OV5QDnh2ogMgD7SVMskNeIriwLU QDbkH67Gm6ToZuJ7earNb5vD5PsPV6ajTMK4gFWyN2/0NIJiR57OUp/xKx/i8LFqJ085 9aKg== X-Received: by 10.152.43.110 with SMTP id v14mr87707lal.4.1430937187510; Wed, 06 May 2015 11:33:07 -0700 (PDT) Original-Received: by 10.25.150.1 with HTTP; Wed, 6 May 2015 11:33:07 -0700 (PDT) In-Reply-To: X-Google-Sender-Auth: 8gz2P3J3gXIY4WX3iR9B8_00VLQ X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22c X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:186294 Archived-At: But that nreverse could be optimized out if the first loop followed a `while'+`setcdr' strategy like the second. 2015-05-06 19:31 GMT+01:00 Artur Malabarba : >>> Looks good, please install. >> >> Not so good as now it is no more destructive for a seq > 100. > > Just pushed the following: > > modified lisp/subr.el > @@ -424,12 +424,12 @@ one is kept." > (unless (gethash elt hash) > (puthash elt elt hash) > (push elt res))) > - (nreverse res)) > + (setcdr list (cdr (nreverse res)))) > (let ((tail list)) > (while tail > (setcdr tail (delete (car tail) (cdr tail))) > - (setq tail (cdr tail)))) > - list)) > + (setq tail (cdr tail))))) > + list)