From nobody Sun Feb 8 15:42:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1574274790; cv=none; d=zoho.com; s=zohoarc; b=XFutuEwt0IsdYoHm2Q0IUL2ZnVtSgdTowMofOyCy48pWvEfOjHR+oDXX6pE/C0dCpo98ruLCZNyXJjuMcPyxwE2mA9YL9K7RiavX/dzQyNoSHQYnTJF1cqv8MV7U0PRJGDiGsLGIHx3j0RHSrdlDgw3lJ+QZ52cMYERa127xUYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574274790; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hrEx3pLbcKJhjeSCY/G7O0EElJohIXjlAIR1HzPYYso=; b=AyWGKEXmy8WVwmY4uKJiUIEZ42l0EZolmjivrzH6WoFU8OS7Wz226jF7BaLZU6VKR3ECJ6klsIg7fzQoLIopna7NjTkcdmpGU/nWLV+3oJHV4yp80z/hJzrBIT8gKFk2xW2nwUvrgCJKgL66yOSdbTjWVDZY5oqP1cm7YQfG1c8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1574274790002103.89842083469716; Wed, 20 Nov 2019 10:33:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-172-nHkA17rUNhqdfnqO0lDeNA-1; Wed, 20 Nov 2019 13:33:05 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E45D107ACC7; Wed, 20 Nov 2019 18:33:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AAA5360BBF; Wed, 20 Nov 2019 18:32:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5A45618089CD; Wed, 20 Nov 2019 18:32:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAKIWsrr013468 for ; Wed, 20 Nov 2019 13:32:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 498B151B6C; Wed, 20 Nov 2019 18:32:54 +0000 (UTC) Received: from icr.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3CF651B65 for ; Wed, 20 Nov 2019 18:32:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574274788; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hrEx3pLbcKJhjeSCY/G7O0EElJohIXjlAIR1HzPYYso=; b=OOnYgPS71Yy8vHTJ9cMjc5QSShU3SnKZ/LPNmRAeZQXIaOBzxJi7P0Abx9aN/ZjzPqLj9e aLDUM8Ts6FbmGEEb5w/TCOUXh1mcf4Kw/b+K1h/BPZ24xuoYuqJkF9ZvF4Fk0l1b1Bkw84 JByYGwvXiQADsAlN+kwqaUHg17VUvw4= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 20 Nov 2019 19:32:45 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] scripts: check-aclrules: use in instead of find X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: nHkA17rUNhqdfnqO0lDeNA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" For checking whether a substring is present in a string, using the pattern: "str" in string is slightly faster than: string.find("str") !=3D -1 Use it to shave off 4 % of the runtime of this script that processes quite a few long source files. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- scripts/check-aclrules.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/check-aclrules.py b/scripts/check-aclrules.py index e06a019b00..d145e59164 100755 --- a/scripts/check-aclrules.py +++ b/scripts/check-aclrules.py @@ -97,7 +97,7 @@ def fixup_name(name): =20 def name_to_ProcName(name): elems =3D [] - if name.find("_") !=3D -1 or name.lower() in ["open", "close"]: + if "_" in name or name.lower() in ["open", "close"]: elems =3D [n.lower().capitalize() for n in name.split("_")] else: elems =3D [name] @@ -116,11 +116,11 @@ with open(proto, "r") as fh: filtered =3D False =20 for line in fh: - if line.find("/**") !=3D -1: + if "/**" in line: incomment =3D True filtered =3D False elif incomment: - if line.find("* @aclfilter") !=3D -1: + if "* @aclfilter" in line: filtered =3D True elif filtered: m =3D re.search(r'''REMOTE_PROC_(.*)\s+=3D\s*\d+''', line) @@ -211,7 +211,7 @@ def process_file(filename): # an ACL function if intable: assign =3D re.search(r'''\.(\w+)\s*=3D\s*(\w+),?''', line) - if line.find("}") !=3D -1: + if "}" in line: intable =3D False table =3D None elif assign is not None: @@ -247,9 +247,9 @@ def process_file(filename): intable =3D True table =3D name =20 - if line.find("{") !=3D -1: + if "{" in line: brace =3D brace + 1 - if line.find("}") !=3D -1: + if "}" in line: brace =3D brace - 1 =20 return errs --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list