From nobody Sat Jul 5 16:16:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152152861626453.309314686614584; Mon, 19 Mar 2018 23:50:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 01E7BC047B89; Tue, 20 Mar 2018 06:50:15 +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 CFF1CC5DAE; Tue, 20 Mar 2018 06:50:14 +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 8D1B0180BADC; Tue, 20 Mar 2018 06:50:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2K6nvUV019578 for ; Tue, 20 Mar 2018 02:49:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 408E05C545; Tue, 20 Mar 2018 06:49:57 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 389F75C70F for ; Tue, 20 Mar 2018 06:49:54 +0000 (UTC) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B4C84C0587C1 for ; Tue, 20 Mar 2018 06:49:53 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id t6so1262812wmt.5 for ; Mon, 19 Mar 2018 23:49:53 -0700 (PDT) Received: from rst.Home ([2a02:c7d:692a:c500:1ebc:73f3:5f60:b131]) by smtp.gmail.com with ESMTPSA id g38sm1923269wra.77.2018.03.19.23.49.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Mar 2018 23:49:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ax0FKeTZFPfd5EJf63LeEvNVhDs9nSdc/GvodOrTy+s=; b=XVo/zZ+PCUTrRzzLoKewMtKw/yKWdHkxorgxbK1v7gUtufQtvJersxjByUJNMoLJlZ /jYFWQpeF5SqSoRdWoqLlFilOJO0Yh6vA2GeA5cYYrOCHjioXd3IcKJO1IjPfTLxkAcQ tETHO6PpbcIt37ssWIzBvM095zIES/Tdbx4NX40BaIrCxAngxOO1cF+T13voDvSqs+bh 292/xnMSisbhYVfVp46gLG0M3p5uvH7NAoe4ZN2AgoHxycCufYB4I5q6MwrOliRE+m+v 10OU48aoYtGiQRI9jCcZc9B4SwutiFDQDRatOmZNelyksku6ahY+YMfgpZiRZG6b6ZB5 k98w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ax0FKeTZFPfd5EJf63LeEvNVhDs9nSdc/GvodOrTy+s=; b=WOR3PnSkxc6O09YW84PpNrr+avDzdSGjowNztGLdgfJpZzB5xCC2FleZmIJ2YWFetA n8XW+qzmhRl686aPAIjv59nP+ku1e4RexZrMhciSqsp3jgMsfEcxT2LesKQGVwyxx73y 1tnWS+dAsyi+ZdXvW7Oubcpf/bu2ARwQ6PMShcRHZazqeqhNw5tlLiKQvDJx+wjCQYmk zgZ3FUjW7x8aKfMB5bV5/F73QN2vk3D+O0GzBIEf7l/qRmCrOVZhVJ+mR90bUH0qR2Ex 8rc5Bmc2qp5Ltk59r2J7tLuIHOUJYzb5ZDvwOcPhmqxWN18hzStiNweYXkO4E3GKTHVI PWTw== X-Gm-Message-State: AElRT7Fmwr47MfKh9V1yq505niCmBU/C5TmYMZ8uHpy+8B3xIKMVqmem Q7KIwB7HD1I3hiGwu5+X1EFNr+w3 X-Google-Smtp-Source: AG47ELtrrcrn7QCZI+Ax9a3fOFtRMNNjTLhRfFLjCohS9UYoY2R6/YBql1/rM8kfADP86jqIKY7baQ== X-Received: by 10.28.84.74 with SMTP id p10mr984049wmi.15.1521528592078; Mon, 19 Mar 2018 23:49:52 -0700 (PDT) From: Radostin Stoyanov To: libvir-list@redhat.com Date: Tue, 20 Mar 2018 06:49:03 +0000 Message-Id: <20180320064908.17723-21-rstoyanov1@gmail.com> In-Reply-To: <20180320064908.17723-1-rstoyanov1@gmail.com> References: <20180320064908.17723-1-rstoyanov1@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 20 Mar 2018 06:49:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 20 Mar 2018 06:49:53 +0000 (UTC) for IP:'74.125.82.65' DOMAIN:'mail-wm0-f65.google.com' HELO:'mail-wm0-f65.google.com' FROM:'rstoyanov1@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.12 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 74.125.82.65 mail-wm0-f65.google.com 74.125.82.65 mail-wm0-f65.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Radostin Stoyanov Subject: [libvirt] [PATCHv2 20/25] apibuild: Simplify type checking of literals 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 20 Mar 2018 06:50:15 +0000 (UTC) X-ZohoMail-DKIM: fail (Computed bodyhash is different from the expected one) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Reduce the number of if-statements used to assign a literals to corresponding class variables. Signed-off-by: Radostin Stoyanov --- docs/apibuild.py | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/docs/apibuild.py b/docs/apibuild.py index 06d556bae..f073b36c7 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -283,24 +283,19 @@ class index: d.set_static(1) =20 if d is not None and name is not None and type is not None: - if type =3D=3D "function": - self.functions[name] =3D d - elif type =3D=3D "functype": - self.functions[name] =3D d - elif type =3D=3D "variable": - self.variables[name] =3D d - elif type =3D=3D "include": - self.includes[name] =3D d - elif type =3D=3D "struct": - self.structs[name] =3D d - elif type =3D=3D "union": - self.unions[name] =3D d - elif type =3D=3D "enum": - self.enums[name] =3D d - elif type =3D=3D "typedef": - self.typedefs[name] =3D d - elif type =3D=3D "macro": - self.macros[name] =3D d + type_map =3D { + "function": self.functions, + "functype": self.functions, + "variable": self.variables, + "include": self.includes, + "struct": self.structs, + "union": self.unions, + "enum": self.enums, + "typedef": self.typedefs, + "macro": self.macros + } + if type in type_map: + type_map[type][name] =3D d else: self.warning("Unable to register type ", type) =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list