From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yoni Rabkin Newsgroups: gmane.emacs.devel Subject: Re: [elpa] externals/emms e9fa4c095d: * emms.el: reverse the order players are collected Date: Wed, 07 Sep 2022 16:16:00 -0400 Message-ID: <87illzym7z.fsf@rabkins.net> References: <166250171605.12534.6807904164286037648@vcs2.savannah.gnu.org> <20220906220156.5255DC0088A@vcs2.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39581"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Sep 07 22:18:12 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oW1Uw-000A4K-R8 for ged-emacs-devel@m.gmane-mx.org; Wed, 07 Sep 2022 22:18:11 +0200 Original-Received: from localhost ([::1]:46832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oW1Uv-00028h-BQ for ged-emacs-devel@m.gmane-mx.org; Wed, 07 Sep 2022 16:18:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59412) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oW1Sv-0001Rn-Rp for emacs-devel@gnu.org; Wed, 07 Sep 2022 16:16:05 -0400 Original-Received: from smtprelay0017.hostedemail.com ([216.40.44.17]:63720 helo=relay.hostedemail.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oW1St-0004Lw-0P for emacs-devel@gnu.org; Wed, 07 Sep 2022 16:16:05 -0400 Original-Received: from omf04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 790AC81105; Wed, 7 Sep 2022 20:16:01 +0000 (UTC) Original-Received: from [HIDDEN] (Authenticated sender: yoni@rabkins.net) by omf04.hostedemail.com (Postfix) with ESMTPA id EBD0D2002B; Wed, 7 Sep 2022 20:16:00 +0000 (UTC) X-Ethics: Use GNU In-Reply-To: (Stefan Monnier's message of "Tue, 06 Sep 2022 21:50:40 -0400") X-Stat-Signature: 5unec8mcwhuyjwn5rohqyhwiareoffig X-Rspamd-Server: rspamout08 X-Rspamd-Queue-Id: EBD0D2002B X-Session-Marker: 796F6E69407261626B696E732E6E6574 X-Session-ID: U2FsdGVkX198tN+HlyIxlscyvZtUHVSV6fmcUzkHECk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rabkins.net; h=from:to:cc:subject:references:date:in-reply-to:message-id:mime-version:content-type:content-transfer-encoding; s=dkim1; bh=TyZCvICE6cEZ7jyAttYR5S2KgqeG1wCnPa/pjcABxpM=; b=m9ag+YHwdWACZU/s6wbP1e/nDbcz5OB6xpIngjWXrkHn3Qea50gnDqbj6jdGVTr7+NRfOn+17rk0D1z3NBX+pAuDpcsPfVrxG0a1aJw8ifz+rWojko1fGTLRP9afyfZK2UTg3SELI99ycAqMVeJtJHblzsxLJOZmnl1oyhP5vD4= X-HE-Tag: 1662581760-556346 Received-SPF: pass client-ip=216.40.44.17; envelope-from=yoni@rabkins.net; helo=relay.hostedemail.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:294879 Archived-At: Stefan Monnier writes: >> --- a/emms.el >> +++ b/emms.el >> @@ -1511,7 +1511,7 @@ If the track can be played by more than one player= , call >> (mapc >> #'(lambda (player) >> (when (funcall (emms-player-get player 'playablep) track) >> - (push player players))) >> + (setq players (append players `(,player))))) >> emms-player-list) >> (if (< 1 (length players)) >> (emms-players-preference track players) > > This changes the code's complexity from O(N) to O(N=C2=B2) in the number = of > players. Is this because append has to traverse the list all of the way to the last cdr every time? > Maybe it's not a very big deal, Indeed. Since the list of players is a constant (about 7), this ends up being constant-time. I tend to ignore how short lists are processed, and I indeed didn't think about big-O of anything when I made this change. > but the standard way to avoid this is to use `push` inside the loop > followed by `nreverse` at the of the loop. Doing it the Right Way (TM) feels better regardless of if it makes any actual sense(*). Programming is about elegance as much as anything else. I'll change it to use push and nreverse. * We've probably spent more time in this conversation than the sum total processing time of all of the machines which will ever run this code. --=20 "Cut your own wood and it will warm you twice"