Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nlw7z-0001ms-CS for mharc-grub-devel@gnu.org; Tue, 03 May 2022 13:15:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlw7w-0001dJ-VZ for grub-devel@gnu.org; Tue, 03 May 2022 13:15:57 -0400 Received: from ionic.de ([2001:41d0:700:3394:1::2]:54471 helo=mail.ionic.de) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlw7u-00059n-EC for grub-devel@gnu.org; Tue, 03 May 2022 13:15:56 -0400 Authentication-Results: root24.eu; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=ionic.de (client-ip=178.162.222.165; helo=178.162.222.165.adsl.inet-telecom.org; envelope-from=ionic@ionic.de; receiver=) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ionic.de; s=default; t=1651598148; bh=N3dQsBlU86n/wwfz/ztRgm0P0m8JtIlRw/VdoENv85s=; h=To:References:From:Subject:Date:In-Reply-To:From; b=sC+fdTjoYGLQqZ8X6PEN4nFTZoc0VF+FfQzlxuRHVj7/SGsWT5I1XdT/w68augtTA VKnliivodxNCZGWOWLPgDKoAWLZrI9a/mKj9/yViwcify6wo6OwOLF39n2SFVrzbyJ WVMCKZe4t19hVaIJo+NHBCWUhMsjWnhNPz7z/iiQ= Received: from [172.22.111.213] (178.162.222.165.adsl.inet-telecom.org [178.162.222.165]) by mail.ionic.de (Postfix) with ESMTPSA id C76B014811D6; Tue, 3 May 2022 19:15:48 +0200 (CEST) To: The development of GNU GRUB , Mathieu Desnoyers References: <20220502141454.706429-1-mathieu.desnoyers@efficios.com> <49a4713d-8101-7bac-bdc8-79146d0072f2@molgen.mpg.de> <285878595.44472.1651588937097.JavaMail.zimbra@efficios.com> From: Mihai Moldovan Subject: Re: [PATCH] grub-mkconfig linux: Fix quadratic algorithm for sorting menu items Message-ID: Date: Tue, 3 May 2022 19:15:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <285878595.44472.1651588937097.JavaMail.zimbra@efficios.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="8GJkrhAkLu0u8QdTdjWSbFBTWD7hfsy8p" Received-SPF: pass client-ip=2001:41d0:700:3394:1::2; envelope-from=ionic@ionic.de; helo=mail.ionic.de 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, NICE_REPLY_A=-0.001, 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: Tue, 03 May 2022 17:15:57 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --8GJkrhAkLu0u8QdTdjWSbFBTWD7hfsy8p Content-Type: multipart/mixed; boundary="BNxPnexC0nb5g7SoKYA6hYcJvN9bcj92Q"; protected-headers="v1" From: Mihai Moldovan To: The development of GNU GRUB , Mathieu Desnoyers Message-ID: Subject: Re: [PATCH] grub-mkconfig linux: Fix quadratic algorithm for sorting menu items References: <20220502141454.706429-1-mathieu.desnoyers@efficios.com> <49a4713d-8101-7bac-bdc8-79146d0072f2@molgen.mpg.de> <285878595.44472.1651588937097.JavaMail.zimbra@efficios.com> In-Reply-To: <285878595.44472.1651588937097.JavaMail.zimbra@efficios.com> --BNxPnexC0nb5g7SoKYA6hYcJvN9bcj92Q Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Just a nit, feel free to ignore it... * On 5/3/22 4:42 PM, Mathieu Desnoyers wrote: > How does the following paragraph sound ? >=20 > ^^^^^^^^ > Here is the improved algorithm proposed: >=20 > - Prepare a list with all the relevant information for ordering by a si= ngle > sort(1) execution. This is done by renaming ".old" suffixes by " 1" a= nd > by suffixing all other files with " 2", thus making sure the ".old" e= ntries > will follow the non-old entries in reverse-sorted-order. > - Call version_reverse_sort on the list (sort -r -V): A single executio= n of > sort(1) will reverse-sort the list in O(n*log(n)) with a merge sort. This is correct for GNU coreutils's sort, but nothing (I'm mostly thinkin= g of SUS/POSIX here) mandates that the sort utility must either use merge sort= or have O(n*log(n)) time complexity. Given that you're using version sort, which is a GNU extension, it probab= ly can't be anything than GNU sort anyway, though, so the point still holds = by implicity. However, this also means that you're adding a hidden dependency upon GNU coreutils sort here, which will hit systems traditionally not using the G= NU userland by default, most prominently BSDs (which, I might add, seem not = to use GRUB by default and generally either discourage it or have thrown it out = of their package management systems). Mihai --BNxPnexC0nb5g7SoKYA6hYcJvN9bcj92Q-- --8GJkrhAkLu0u8QdTdjWSbFBTWD7hfsy8p Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsF5BAABCAAjFiEEbhHQj3UzgcdE8cg8H9Yu2W4lOocFAmJxY0MFAwAAAAAACgkQH9Yu2W4lOocV 8g/9HSCcmwyujejfdpsPbfYPWYnjbzOZ+OcUxYJDlP8MMkfN2SWKOjQtWzkwo2vAVu4GROYpIWLH lWv8HvafE0XDQNhQiKdWcULv1+LZqhRghRbxU83eI73e4n7KZNyVlbbLTpBx/uxq5Ut4HQ4bxjci +Kn+NM0jhSnxCzNaKyCgadJg6Wtlj6Td/1sDoOs/c06Qtl5jDiJHs1J3vLPlAtxPd40TVlDny+eZ dwjjC3q+zscRqbInLGsA9I4CyggFkpdrSfIn6Y2WP4JI8kgNIymk5d4iAvdgYX2NpVjLPQ+ROCSN rayv+hBc7mYYBpywdP4ACuWrWOYuaj77GuUFz1/gOHEkoRI0UnlrzdL2/GzdY1oNiVJVSHxRacvq oM590LPsme5GXpDiGXUo3/K6LMPlcXSfIPmdKPXtxP4/LgfskD2IZkdFBhasWYVXb06X1p/MvLzY 6COmZnc+MZVocCY/oR05gS+OuCUlh0YVpNweLPREktCkQ+r3aJl0WXSXtDNz9GbWo7tiB8ZJS7Z6 XRAOA1iHiEhlQJ4KmAnxs8sHod9wXX8X2wdkaUKP+H5+1K6vWq/2GtWHBGkXa0qKhKTmoev6xDDD XZ1/XTEVmifRXi5ebzOXcm8Ia0sHw2OVx9t3kETQ362RU+GYFUO1H6TYfyu5ki2nshcMTAK/d28+ ijA= =sCxQ -----END PGP SIGNATURE----- --8GJkrhAkLu0u8QdTdjWSbFBTWD7hfsy8p--