From cbde13850f1334ef3019288096ccd95dfcdaec6e Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 17 Aug 2020 15:33:39 +0200 Subject: [PATCH] ninjabackend: avoid lambdas The lambda in NinjaBuildElement.write is quite expensive, totalling 0.3s just to do a couple function calls. Since it is used just once, simply inline it. On a QEMU build, the total time spent in write from this series goes from 5.321s to 3.238s, though part of it can be attributed to previous patches. --- mesonbuild/backend/ninjabackend.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index fd8be0098..3a5c10252 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -386,10 +386,9 @@ class NinjaBuildElement: newelems = [] for i in elems: if not should_quote or i == '&&': # Hackety hack hack - quoter = ninja_quote + newelems.append(ninja_quote(i)) else: - quoter = lambda x: ninja_quote(qf(x)) - newelems.append(quoter(i)) + newelems.append(ninja_quote(qf(i))) line += ' '.join(newelems) line += '\n' outfile.write(line)