From nobody Sun Apr 30 06:58:20 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Q8HHJ4JPrz48sBq; Sun, 30 Apr 2023 06:58:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q8HHJ3RnTz3PHQ; Sun, 30 Apr 2023 06:58:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682837900; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=x+rYSulscsbK+XnkbVRd7x11dd2GIqH1Lyc/Xrfouvs=; b=MwdvJklLopOqBJ5ybUUpOfWYuQcWZ0vIQZBjdVZDojL0yK9n0suPj1s9gK0UjstpCGtRPB q9Trnf6hb851DX6EQ8mUkkb++UeK3Yk++HubBw+gVTfo/rPp0eDPJUc8B4GU0VriZiKrhW 1AwlKsel8ECsFE8vHatR9xcq6k3dj31VqrCcMLGT8gLUl4dXdUxaR6Xix32G3hXsprl+zp 270o8R08kNudEJCWzr7bH1bkGPpCqF47TRehLSuHw0uso13a0tf5W58ZVPaEy2XxOkSZyV vD/0okWcwaBxAEuyE6moTBoUG1h5EjE2JsomUQUDwnw6Yk4719quxY0mp7hRRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682837900; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=x+rYSulscsbK+XnkbVRd7x11dd2GIqH1Lyc/Xrfouvs=; b=AMf2FBZmEZy4aXsLLTdjuqrsdUSDRywEcEgvpS1mI3Zk0QZ5BJE9qwk+GqXQJg8ltbcwwv pyi3xr0ECxxr6UldSlW3Nr9fXxKdfVLAmNXU3zU5kU11lpHosXiNkRR9XO/8bPdwCL9X9s eebr4yXf601sccaoZnbD4lC0HpLFAUuB6SP28f8PYNFc7uJ4ZlgOZijyQwe5aONoZ54+3V /ftUNZhl7YMOeORcoXgDdPjpQmPFb6Ox7uIIzLKI4WxqMcsf8NFc1NqHAPnm+TTU9iQLBz egUfhTQXHPtpQQ4sHdVZJ06DIx/GaPVmkQHWuBn+pZI0Y/0/9WxWqxkmFmN1Qw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682837900; a=rsa-sha256; cv=none; b=dSgSiqOhxTgwRSuIY7xGnrVK1wKOckP31ni549AIEhh+G2DJhobGeGOZ0ln3CPbV9gvAR+ 84cEuIIRfVgqd61IhrQ3aUuRedBW3v84wgXBhMD8CGelmZPvfsLH0UkIunXkmf/aUDZ8U4 Z2i4QortWOVS+F6NbmKqSaOmaXZYQJjqWXB54bY3Ijav9O7JuCgXoR8kaUkOlhl4qdaikt dgSZcdGx2+HUNBHMY8m+TAmYJ68Lu/Dsf78dVEXuzoWbgiKoxWXHuoUFIHGe1enwVlyetE EZyVgfDEOl6B73bCcaz6/uB6uiRyZWcVPbXMBE40qLVKKL6MPcW5reEn862fJA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Q8HHJ2Wzjz1Ccf; Sun, 30 Apr 2023 06:58:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33U6wKtH072045; Sun, 30 Apr 2023 06:58:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33U6wKgN072044; Sun, 30 Apr 2023 06:58:20 GMT (envelope-from git) Date: Sun, 30 Apr 2023 06:58:20 GMT Message-Id: <202304300658.33U6wKgN072044@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: 49012db42f3d - stable/13 - libc: Sorting is not needed when there are less than two elements List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 49012db42f3d0bf29958e1248d1c45312815be05 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=49012db42f3d0bf29958e1248d1c45312815be05 commit 49012db42f3d0bf29958e1248d1c45312815be05 Author: Hans Petter Selasky AuthorDate: 2023-04-19 10:18:56 +0000 Commit: Hans Petter Selasky CommitDate: 2023-04-30 06:56:20 +0000 libc: Sorting is not needed when there are less than two elements If there are less than two elements avoid executing the first sorting loop. No functional change intended. Reviewed by: kib@ Sponsored by: NVIDIA Networking Differential Revision: https://reviews.freebsd.org/D39691 (cherry picked from commit ecb2ce3a51e9b09a57cd42262fc798ae089c0758) --- lib/libc/stdlib/qsort.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libc/stdlib/qsort.c b/lib/libc/stdlib/qsort.c index 015c648d633a..410118c5cd70 100644 --- a/lib/libc/stdlib/qsort.c +++ b/lib/libc/stdlib/qsort.c @@ -108,7 +108,8 @@ local_qsort(void *a, size_t n, size_t es, cmp_t *cmp, void *thunk) int cmp_result; int swap_cnt; - if (__predict_false(n == 0)) + /* if there are less than 2 elements, then sorting is not needed */ + if (__predict_false(n < 2)) return; loop: swap_cnt = 0;