From nobody Wed Apr 19 15:18:14 2023 X-Original-To: dev-commits-src-main@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 4Q1kvC6RTWz4663y; Wed, 19 Apr 2023 15:18:15 +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 4Q1kvC1Zc7z46gJ; Wed, 19 Apr 2023 15:18:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681917495; 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=3WeK+A2GwUNMdVquCm3X2fHEJIuKDAVYP2TdKFNm8uE=; b=avZZovs0qIRwcSmWO5FVUm+HGu4ln9I7fK4YdDhUqZ2ciQPMMpvSZ8G4n0PmrvIcFJEbV6 xN90SouIRZit5nFFKrgiXnl1nCKE6GnR/ZTFqopMcRyB3NktDY1s+V2jvnj8JF99L0HL7m Pe21RiHeF44JbDXLO6uSQz2PQiJNoN5BvzVT9+x7SgnxxUfKWibn4gPLy33FPtjBevEAnk iFa1YGvjzDyhzWAGKZO9ADZebp1p+02YnhuAkcyXgCH/T1d2Dw8sa7PVGmVz7vblqELiee cF95r8FDgxYlIwasHJuAiGHWQCQFm8xhWuFCfDbfQcngr21SeYohV4dHy7quCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681917495; 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=3WeK+A2GwUNMdVquCm3X2fHEJIuKDAVYP2TdKFNm8uE=; b=es9CZKEUOlasqVF9ay1/wsexmyt6mwVl0uuHgqxoFvcbqKN+Sja6QYkCTdUKQD0xUOtns4 C1PkTlPFzhlHHxF0j6CLmzXBLeVNR3N4OnV9nxbL7TJB1Ml+Dwvszi3YM4hp+VtQTppHa2 987pqo2+VahxmjWR/0eNOwNlUZb2vnnsBL4dQFN6dWWAqVxgSEh8pywHiJ5wfy4IDei680 dGXu3U8ZAayB2E95RR7CYqRzixfdc6EgiadzcJhihoaxcIsMDKn8NFREOtIBe8kryikMFl PB1wVNG9jpevmti+zFGbPPYvZWLubmlEa2LyyVHRK5gEXaQ3j+BXRuqL2LEXig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681917495; a=rsa-sha256; cv=none; b=KjRrt7GLBBYSgmRpkG7L7Xsj54mDAIYSbY8NF+9+RbBfnH3z50vx1UIJFY3srupbiwWsMV FMzNLb7EmuWZnj2wS38Vlg9oG2AMdM9f94bQAZFh9XcTonBVkMzSdIcduPe/95T45ESrnE LYIBQaa4f9aZe4ur+sf1ahubG8Xr57IuNi63UoW0Q1iqvBJpydrJn1d8Dv0FwZEr8qPklv tS8Kg8uPBz9kEQF9XbcDM8dTX7uUDFMTpIaS1ztk6A5ACtFry1tyuH+thnzrIcghRZxhei PA8+pYozWxpSLLYtgytU+rGlgrqz+sx7g67iyYnUa9cUbZUxLK1zps3s3SA/9Q== 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 4Q1kvC0Ztgz10SP; Wed, 19 Apr 2023 15:18:15 +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 33JFIEjl075822; Wed, 19 Apr 2023 15:18:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33JFIEA7075821; Wed, 19 Apr 2023 15:18:14 GMT (envelope-from git) Date: Wed, 19 Apr 2023 15:18:14 GMT Message-Id: <202304191518.33JFIEA7075821@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: ecb2ce3a51e9 - main - libc: Sorting is not needed when there are less than two elements List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: ecb2ce3a51e9b09a57cd42262fc798ae089c0758 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=ecb2ce3a51e9b09a57cd42262fc798ae089c0758 commit ecb2ce3a51e9b09a57cd42262fc798ae089c0758 Author: Hans Petter Selasky AuthorDate: 2023-04-19 10:18:56 +0000 Commit: Hans Petter Selasky CommitDate: 2023-04-19 15:17:33 +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@ MFC after: 1 week Sponsored by: NVIDIA Networking Differential Revision: https://reviews.freebsd.org/D39691 --- 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 425edd562420..0d65cd119ea6 100644 --- a/lib/libc/stdlib/qsort.c +++ b/lib/libc/stdlib/qsort.c @@ -114,7 +114,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;