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.
pull/7607/head
Paolo Bonzini 4 years ago
parent b14601da7b
commit cbde13850f
  1. 5
      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)

Loading…
Cancel
Save