From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id DB94915808B for ; Sun, 27 Mar 2022 23:07:17 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B0B4EE079E; Sun, 27 Mar 2022 23:07:15 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3C815E0978 for ; Sun, 27 Mar 2022 23:07:13 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (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) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 06F183436A0 for ; Sun, 27 Mar 2022 23:07:12 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 73FFD34A for ; Sun, 27 Mar 2022 23:07:10 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1648422401.9b843f5c9d0a5bdd4a57efb5bd5f41c4736d4dcf.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/ X-VCS-Repository: proj/portage X-VCS-Files: lib/portage/checksum.py lib/portage/data.py lib/portage/dispatch_conf.py X-VCS-Directories: lib/portage/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 9b843f5c9d0a5bdd4a57efb5bd5f41c4736d4dcf X-VCS-Branch: master Date: Sun, 27 Mar 2022 23:07:10 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: da10ac33-bf1f-48de-8010-69e2ebd62b0a X-Archives-Hash: c387a29c4ec138e6f992bc5ca127ffe5 commit: 9b843f5c9d0a5bdd4a57efb5bd5f41c4736d4dcf Author: Kenneth Raplee kennethraplee com> AuthorDate: Tue Mar 22 07:46:22 2022 +0000 Commit: Sam James gentoo org> CommitDate: Sun Mar 27 23:06:41 2022 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=9b843f5c Consolidate nested conditional branches Depending how a conditional is wrote, its nested conditional can be consolidated into its own expression by using the `and` or `or` boolean operators for the same effect. These kinds of refactors give processors better chances at branch prediction and would make these conditionals less expensive than they might have been. Signed-off-by: Kenneth Raplee kennethraplee.com> Signed-off-by: Sam James gentoo.org> lib/portage/checksum.py | 5 ++--- lib/portage/data.py | 9 ++------- lib/portage/dispatch_conf.py | 18 +++++++++++------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/portage/checksum.py b/lib/portage/checksum.py index 3b5a10d24..d7e800c47 100644 --- a/lib/portage/checksum.py +++ b/lib/portage/checksum.py @@ -427,9 +427,8 @@ class _hash_filter: for token in self._tokens: if token in matches: return True - if token[:1] == "-": - if token[1:] in matches: - return False + if token[:1] == "-" and token[1:] in matches: + return False return False diff --git a/lib/portage/data.py b/lib/portage/data.py index de7d88e5e..b73fa8882 100644 --- a/lib/portage/data.py +++ b/lib/portage/data.py @@ -158,15 +158,12 @@ def _get_global(k): unprivileged = _unprivileged_mode(eroot_or_parent, eroot_st) v = 0 - if uid == 0: - v = 2 - elif unprivileged: + if uid == 0 or unprivileged: v = 2 elif _get_global("portage_gid") in os.getgroups(): v = 1 elif k in ("portage_gid", "portage_uid"): - # Discover the uid and gid of the portage user/group keyerror = False try: @@ -357,9 +354,7 @@ def _init(settings): if "secpass" not in _initialized_globals: v = 0 - if uid == 0: - v = 2 - elif "unprivileged" in settings.features: + if uid == 0 or "unprivileged" in settings.features: v = 2 elif portage_gid in os.getgroups(): v = 1 diff --git a/lib/portage/dispatch_conf.py b/lib/portage/dispatch_conf.py index c89caf087..d682a9ad0 100644 --- a/lib/portage/dispatch_conf.py +++ b/lib/portage/dispatch_conf.py @@ -238,13 +238,17 @@ def rcs_archive(archive, curconf, newconf, mrgconf): _archive_copy(mystat, newconf, archive) - if has_branch: - if mrgconf and os.path.isfile(archive) and os.path.isfile(mrgconf): - # This puts the results of the merge into mrgconf. - ret = os.system(f"rcsmerge -p -r{RCS_BRANCH} '{archive}' > '{mrgconf}'") - os.chmod(mrgconf, mystat.st_mode) - os.chown(mrgconf, mystat.st_uid, mystat.st_gid) - os.rename(archive, archive + ".dist.new") + if ( + has_branch + and mrgconf + and os.path.isfile(archive) + and os.path.isfile(mrgconf) + ): + # This puts the results of the merge into mrgconf. + ret = os.system(f"rcsmerge -p -r{RCS_BRANCH} '{archive}' > '{mrgconf}'") + os.chmod(mrgconf, mystat.st_mode) + os.chown(mrgconf, mystat.st_uid, mystat.st_gid) + os.rename(archive, f"{archive}.dist.new") return ret