From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nmbv4-0008F7-Dn for mharc-grub-devel@gnu.org; Thu, 05 May 2022 09:53:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmbv3-0008Di-CI for grub-devel@gnu.org; Thu, 05 May 2022 09:53:25 -0400 Received: from mail.efficios.com ([167.114.26.124]:54848) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmbuz-0008C1-Gc for grub-devel@gnu.org; Thu, 05 May 2022 09:53:24 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 7B3E23C1235; Thu, 5 May 2022 09:53:20 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id v4HizZjoczIF; Thu, 5 May 2022 09:53:19 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id C73ED3C1233; Thu, 5 May 2022 09:53:19 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com C73ED3C1233 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1651758799; bh=Ows5fhgXDmIdkeS+dYxEP9VRFRrSEc1Z7VTOomChxPA=; h=Date:From:To:Message-ID:MIME-Version; b=ZnQpu3mmuwE2CZf1S+0/0FQR2oUUJkGgc8jbeNDXEVdBTiuvVLTzM/fsntJy4brl2 ASsHmnTrQi76lnj/nhH6ypF7l4d8kxPghG3A18a4Cj/jUUxuskMFvTt+8CMnVCmQRV 8ohM6AOxhImXK3T3snPTjyVuj+EQjfk0mldHnlFKZernRR4R6DpgCErsOzjcd2vntk auyF9axPe/yAbE927VGf91dizNG+FpCSzArM2StO1kVL6XHUE8U5sFIu5BDAPx0p3G B0uxL6jNYwWLl6cV7064H/yMMgJAvsMJMDPdeNzX2G/QDszO4KOJ95i6GccbqPGzmp 8hBDbavjPjSuw== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ZCrnQWSqwhKc; Thu, 5 May 2022 09:53:19 -0400 (EDT) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id B92903C140C; Thu, 5 May 2022 09:53:19 -0400 (EDT) Date: Thu, 5 May 2022 09:53:19 -0400 (EDT) From: Mathieu Desnoyers To: Robbie Harwood Cc: Daniel Kiper , Vladimir phcoder Serbinenko , grub-devel , Paul Menzel Message-ID: <229634522.46806.1651758799621.JavaMail.zimbra@efficios.com> In-Reply-To: <1540694996.45617.1651677847725.JavaMail.zimbra@efficios.com> References: <20220503153812.991408-1-mathieu.desnoyers@efficios.com> <1540694996.45617.1651677847725.JavaMail.zimbra@efficios.com> Subject: Re: [PATCH v2] grub-mkconfig linux: Fix quadratic algorithm for sorting menu items MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.26.124] X-Mailer: Zimbra 8.8.15_GA_4257 (ZimbraWebClient - FF100 (Linux)/8.8.15_GA_4257) Thread-Topic: grub-mkconfig linux: Fix quadratic algorithm for sorting menu items Thread-Index: Z7884qEjOjUcI+SWNptOHhBHpOmCuw/o7M77 Received-SPF: pass client-ip=167.114.26.124; envelope-from=compudj@efficios.com; helo=mail.efficios.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 May 2022 13:53:25 -0000 ----- On May 4, 2022, at 11:24 AM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote: > ----- On May 4, 2022, at 10:43 AM, Robbie Harwood rharwood@redhat.com wrote: > >> Mathieu Desnoyers writes: >> >>> +version_reverse_sort () >>> +{ >>> + case $version_reverse_sort_sort_has_v in >> >> Does this need to be its own variable, or could it just reuse >> version_sort_sort_has_v? > > We could do that, assuming that both sort -r -V and sort -V always work (or > don't) > in the same way. > > Then I would change the test in version_reverse_sort to: > > if sort -V /dev/null 2>&1; then > > There is no point in calling this check with "-r" if it sets > version_sort_sort_has_v. > >> >>> +reverse_sorted_list=$(echo $list | tr ' ' '\n' | sed 's/$/ 2/' | sed 's/\.old >>> 2/ 1/' | version_reverse_sort | sed 's/ 1$/.old/' | sed 's/ 2$//') >> >> Could the `sed | sed` pattern be collapsed into a single invocation >> using multiple -e switches?1 > > I think we can straightforwardly turn "| sed 's/ 1$/.old/' | sed 's/ 2$//'" > into "| sed -e 's/ 1$/.old/' -e 's/ 2$//'". > > How to match that all lines ending with ".old" need to be replaced with a > " 1" suffix, and all _other_ lines need to be suffixed with " 2" in a single > sed invocation is unclear to me. Any idea ? Actually with sed -e 's/$/ 2/' -e 's/\.old 2$/ 1/' the second -e applies on the result of the first, so I can just do that. Thanks, Mathieu > > Thanks, > > Mathieu > >> >> Be well, >> --Robbie > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com