From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nmGrN-0001yn-Pt for mharc-grub-devel@gnu.org; Wed, 04 May 2022 11:24:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmGrM-0001wQ-Es for grub-devel@gnu.org; Wed, 04 May 2022 11:24:12 -0400 Received: from mail.efficios.com ([167.114.26.124]:58116) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmGrK-00040Y-M0 for grub-devel@gnu.org; Wed, 04 May 2022 11:24:12 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 3F00F2EFC05; Wed, 4 May 2022 11:24:08 -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 okFPI2Ohpm-b; Wed, 4 May 2022 11:24:07 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id D5C3E2EF8BF; Wed, 4 May 2022 11:24:07 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com D5C3E2EF8BF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1651677847; bh=d4CMeA7yVnlXlpiYxz/mNBKr+0EGN7s9Nzw9SrFXTzk=; h=Date:From:To:Message-ID:MIME-Version; b=MdJsLBDYzQUhX5uTMTZCUbv90nyeGw/sU5scP2UnSJS5KRIUJAqbLVUZ82rWV93S5 3+piguCEg9ZiyX/KeJLL1crVZ125h/teMIWhORG5pJ+e0aflgJ96K5iscW1rgoqoA7 kmQqBJ1Xv5LI2B/8ErJnVMR5is1x8u5n5sOxIFmZZ1cD+t6rPfGSZGYLNIy+qW6KTy 9p7c7XvLX+8Ah6ri5KlTzfn/aWV94ulbxu8eGAhCtQB5QAQyiCKNnXu7nkZ746HZqP ijsjHyvm2Mq2QRwI+csI0X4I5JfyfLDfFhN7i4qXKYh29kOXl7W7WtP06CaxjUq/Cz 4uquCMybwKhVw== 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 s4aoK9yGW2iL; Wed, 4 May 2022 11:24:07 -0400 (EDT) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id C8E922EF8BC; Wed, 4 May 2022 11:24:07 -0400 (EDT) Date: Wed, 4 May 2022 11:24:07 -0400 (EDT) From: Mathieu Desnoyers To: Robbie Harwood Cc: Daniel Kiper , Vladimir phcoder Serbinenko , grub-devel , Paul Menzel Message-ID: <1540694996.45617.1651677847725.JavaMail.zimbra@efficios.com> In-Reply-To: References: <20220503153812.991408-1-mathieu.desnoyers@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== 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: Wed, 04 May 2022 15:24:12 -0000 ----- 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 ? Thanks, Mathieu > > Be well, > --Robbie -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com