From patchwork Thu May 15 12:00:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 23366 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id AAAEFC3220 for ; Thu, 15 May 2025 12:00:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C42D168D73; Thu, 15 May 2025 14:00:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="pPSNfBRO"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C4B5C68B6C for ; Thu, 15 May 2025 14:00:16 +0200 (CEST) Received: from pb-laptop.local (185.221.142.248.nat.pool.zt.hu [185.221.142.248]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 878F189A; Thu, 15 May 2025 13:59:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1747310399; bh=l7yybGVLafH1XWOnEm8igYUsDS7khbHK2rEVGgdAMBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pPSNfBROxfU0GJ3vBFL50KJWyr12bBK8jiWVSnOTiob9U3JMVx339MrAqA7/VvQgN AuoFwgB/kuNcIMBxmFmO0WXwWS/JtTFtzYvsqEi9Gh5hq3zxFHNlep1AJUHEbtmv5e fHeRFTVifEtTcLf7m/eVHIJdJkS64SR3/E+QggS4= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Paul Elder Subject: [RFC PATCH v1 1/8] utils: codegen: ipc: Use `any()` instead of `len([]) > 0` Date: Thu, 15 May 2025 14:00:05 +0200 Message-ID: <20250515120012.3127231-2-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250515120012.3127231-1-barnabas.pocze@ideasonboard.com> References: <20250515120012.3127231-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use `any()` with a generator expression instead of constructing a list and checking its length. Signed-off-by: Barnabás Pőcze Reviewed-by: Paul Elder --- .../ipc/generators/mojom_libcamera_generator.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/utils/codegen/ipc/generators/mojom_libcamera_generator.py b/utils/codegen/ipc/generators/mojom_libcamera_generator.py index d9c620a05..eff29a5b8 100644 --- a/utils/codegen/ipc/generators/mojom_libcamera_generator.py +++ b/utils/codegen/ipc/generators/mojom_libcamera_generator.py @@ -166,7 +166,7 @@ def MethodParamOutputs(method): return method.response_parameters[1:] def MethodParamsHaveFd(parameters): - return len([x for x in parameters if HasFd(x)]) > 0 + return any(x for x in parameters if HasFd(x)) def MethodInputHasFd(method): return MethodParamsHaveFd(method.parameters) @@ -465,9 +465,9 @@ class Generator(generator.Generator): 'cmd_event_enum_name': '_%sEventCmd' % self.module_name, 'consts': self.module.constants, 'enums': self.module.enums, - 'has_array': len([x for x in self.module.kinds.keys() if x[0] == 'a']) > 0, - 'has_map': len([x for x in self.module.kinds.keys() if x[0] == 'm']) > 0, - 'has_string': len([x for x in self.module.kinds.keys() if x[0] == 's']) > 0, + 'has_array': any(x for x in self.module.kinds.keys() if x[0] == 'a'), + 'has_map': any(x for x in self.module.kinds.keys() if x[0] == 'm'), + 'has_string': any(x for x in self.module.kinds.keys() if x[0] == 's'), 'has_namespace': self.module.mojom_namespace != '', 'interface_event': GetEventInterface(self.module.interfaces), 'interface_main': GetMainInterface(self.module.interfaces), @@ -485,9 +485,9 @@ class Generator(generator.Generator): return { 'consts': self.module.constants, 'enums_gen_header': [x for x in self.module.enums if x.attributes is None or 'skipHeader' not in x.attributes], - 'has_array': len([x for x in self.module.kinds.keys() if x[0] == 'a']) > 0, - 'has_map': len([x for x in self.module.kinds.keys() if x[0] == 'm']) > 0, - 'has_string': len([x for x in self.module.kinds.keys() if x[0] == 's']) > 0, + 'has_array': any(x for x in self.module.kinds.keys() if x[0] == 'a'), + 'has_map': any(x for x in self.module.kinds.keys() if x[0] == 'm'), + 'has_string': any(x for x in self.module.kinds.keys() if x[0] == 's'), 'structs_gen_header': [x for x in self.module.structs if x.attributes is None or 'skipHeader' not in x.attributes], 'structs_gen_serializer': [x for x in self.module.structs if x.attributes is None or 'skipSerdes' not in x.attributes], }