summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-01-08 14:13:04 +0100
committerEli Schwartz <eschwartz93@gmail.com>2025-01-08 13:45:26 -0500
commit4151d09e262f48b3e06e6677581465758e08b79d (patch)
tree211053147412dce23946c6b646af3b8f01975e20
parent7fd138dad98d698c9305c466f500a1df4fb0d74d (diff)
downloadmeson-4151d09e262f48b3e06e6677581465758e08b79d.tar.gz
ninjabackend: convert _should_use_rspfile to a lazy_property
_should_use_rspfile() is expensive due to the call to length_estimate(). Make it a lazy property so that it is only called once. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--mesonbuild/backend/ninjabackend.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 7e353c0af..040f3add6 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2012-2017 The Meson development team
-# Copyright © 2023-2024 Intel Corporation
+# Copyright © 2023-2025 Intel Corporation
from __future__ import annotations
@@ -351,6 +351,7 @@ class NinjaBuildElement:
if name == 'DEPFILE':
self.elems.append((name + '_UNQUOTED', elems))
+ @mesonlib.lazy_property
def _should_use_rspfile(self) -> bool:
# 'phony' is a rule built-in to ninja
if self.rulename == 'phony':
@@ -368,7 +369,7 @@ class NinjaBuildElement:
def count_rule_references(self) -> None:
if self.rulename != 'phony':
- if self._should_use_rspfile():
+ if self._should_use_rspfile:
self.rule.rsprefcount += 1
else:
self.rule.refcount += 1
@@ -381,7 +382,7 @@ class NinjaBuildElement:
implicit_outs = ' '.join([ninja_quote(i, True) for i in self.implicit_outfilenames])
if implicit_outs:
implicit_outs = ' | ' + implicit_outs
- use_rspfile = self._should_use_rspfile()
+ use_rspfile = self._should_use_rspfile
if use_rspfile:
rulename = self.rulename + '_RSP'
mlog.debug(f'Command line for building {self.outfilenames} is long, using a response file')