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 22:18:14 +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: multipart/alternative; boundary=001a11c243e2470f9905157055e4 X-Trace: ger.gmane.org 1430947116 19636 80.91.229.3 (6 May 2015 21:18:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 6 May 2015 21:18:36 +0000 (UTC) Cc: emacs-devel , Thierry Volpiatto To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 06 23:18:35 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 1Yq6iA-00059d-I7 for ged-emacs-devel@m.gmane.org; Wed, 06 May 2015 23:18:34 +0200 Original-Received: from localhost ([::1]:47100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yq6i9-0000Jh-ED for ged-emacs-devel@m.gmane.org; Wed, 06 May 2015 17:18:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yq6ht-0000Ij-2M for emacs-devel@gnu.org; Wed, 06 May 2015 17:18:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yq6hs-0000hT-4s for emacs-devel@gnu.org; Wed, 06 May 2015 17:18:17 -0400 Original-Received: from mail-la0-x235.google.com ([2a00:1450:4010:c03::235]:33960) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yq6hr-0000g9-T5 for emacs-devel@gnu.org; Wed, 06 May 2015 17:18:16 -0400 Original-Received: by laat2 with SMTP id t2so16925945laa.1 for ; Wed, 06 May 2015 14:18:14 -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=lURxYO1g+pX9yK3tWGi64Dh/+JFn4FnSNACOVW+sykQ=; b=g1bbrYyA0i/kWjseHPr71nDfJyiM7/NiqMj3vEf/NDNFAWylj3lgJqu1SZ2uLoX0MN ziZc7CSjzk84r9oKrrZiE8Kx+elygfujPCb6nybgwxH6YviuvU8QQpharI7/KbZqg5Qx XPUzPK/8Jlmb6pYAQIRcn0wYbraTnmGwxofal7j4FqA7ZIHj/+5kaF9tvNkqLCvl1OfI A4hWwR4h54CtiLHsJfCOhOz79dzY2oYJDNZgza8i0xiKeqGI6rD7FhMiyPvPVeCSqCrM XcIsq9fsKr6HjwNPJK4s1ecs5geePCL3fv2PntFbGt3+myzAZ36MyvACjeS0ajB2UNCF JKUw== X-Received: by 10.152.7.239 with SMTP id m15mr468380laa.95.1430947094792; Wed, 06 May 2015 14:18:14 -0700 (PDT) Original-Received: by 10.25.150.1 with HTTP; Wed, 6 May 2015 14:18:14 -0700 (PDT) Original-Received: by 10.25.150.1 with HTTP; Wed, 6 May 2015 14:18:14 -0700 (PDT) In-Reply-To: X-Google-Sender-Auth: Oz6m8vhlnFiQAoUmEsBsRjzXkcU X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::235 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:186304 Archived-At: --001a11c243e2470f9905157055e4 Content-Type: text/plain; charset=UTF-8 On May 6, 2015 9:54 PM, "Stefan Monnier" wrote: > > >>> Looks good, please install. > >> Not so good as now it is no more destructive for a seq > 100. > > Not being destructive doesn't seem like a serious problem to me. Usually, yes. But here the docstring specifically documents that "Destructively remove `equal' duplicates from LIST. Store the result in LIST and return it." > > > 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)))) > > I don't understand what this is intended to do. It destructively modifies list to be equal to (nreverse res). The car is already the same, so only the cdr needs to be modified. --001a11c243e2470f9905157055e4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On May 6, 2015 9:54 PM, "Stefan Monnier" <monnier@iro.umontreal.ca> wrote:
>
> >>> Looks good, please install.
> >> Not so good as now it is no more destructive for a seq > 1= 00.
>
> Not being destructive doesn't seem like a serious problem to me.

Usually, yes. But here the docstring specifically documents = that "Destructively remove `equal' duplicates from LIST.
Store the result in LIST and return it."

>
> > modified=C2=A0 =C2=A0lisp/subr.el
> > @@ -424,12 +424,12 @@ one is kept."
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (unless (gethash elt has= h)
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (puthash elt elt = hash)
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (push elt res)))<= br> > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 (nreverse res))
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 (setcdr list (cdr (nreverse res))))<= br> >
> I don't understand what this is intended to do.

It destructively modifies list to be equal to (nreverse res)= . The car is already the same, so only the cdr needs to be modified.

--001a11c243e2470f9905157055e4--