summaryrefslogtreecommitdiff
path: root/mesonbuild/arglist.py
AgeCommit message (Collapse)Author
2025-03-01arglist: post is only appended to, make it a listPaolo Bonzini
self.post is only ever appended to on the right hand. However, it is then reversed twice in flush_pre_post(), by using "for a in reversed.post()" and appendleft() within the loop. It would be tempting to use appendleft() in __iadd__ to avoid the call to reversed(), but that is not a good idea because the loop of flush_pre_post() is part of a slow path. It's rather more important to use a fast extend-with-list-argument in the fast path where needs_override_check if False. For clarity, and to remove the temptation, make "post" a list instead of a deque. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-03-01arglist: optimize flush_pre_post(), and __iadd__() with itPaolo Bonzini
Unless an argument is marked as Dedup.OVERRIDDEN, pre_flush_set and post_flush_set will always be empty and the loops in flush_pre_post() will not be doing anything interesting: for a in self.pre: dedup = self._can_dedup(a) if a not in pre_flush_set: # This just makes new a copy of self.pre new.append(a) if dedup is Dedup.OVERRIDDEN: # this never happens pre_flush_set.add(a) for a in reversed(self.post): dedup = self._can_dedup(a) if a not in post_flush_set: # Here self.post is reversed twice post_flush.appendleft(a) if dedup is Dedup.OVERRIDDEN: # this never happens post_flush_set.add(a) new.extend(post_flush) In this case it's possible to avoid expensive calls and loops, instead relying as much on Python builtins as possible. Track whether any options have that flag and if not just concatenate pre, _container and post. Before: ncalls tottime cumtime 45127 0.251 4.530 arglist.py:142(__iter__) 81866 3.623 5.013 arglist.py:108(flush_pre_post) 76618 3.793 5.338 arglist.py:273(__iadd__) After: 35647 0.156 0.627 arglist.py:160(__iter__) 78998 2.627 3.603 arglist.py:116(flush_pre_post) 73774 3.605 5.049 arglist.py:292(__iadd__) The time in __iadd__ is reduced because it calls __iter__, which flushes pre and post. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-03-01arglist: optimize __init__()Paolo Bonzini
"Inline" CompilerArgs.__iter__() into CompilerArgs.__init__(), so that replace list(Iterable) is replaced by the much faster list(List). Before: ncalls tottime cumtime 19268 0.163 3.586 arglist.py:97(__init__) After: ncalls tottime cumtime 18674 0.211 3.442 arglist.py:97(__init__) Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-12-27arglist: De-dup arg prefixes only when they are used as a prefixNirbheek Chauhan
This was already done for dedup2_prefixes, also do it for dedup1_prefixes, and move export-dynamic to dedup1_args, where it belongs. Also modify some comments around this to clearly distinguish standalone argument matching and argument-prefix matching.
2023-12-13Use SPDX-License-Identifier consistentlyDylan Baker
This replaces all of the Apache blurbs at the start of each file with an `# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing uses to be consistent in capitalization, and to be placed above any copyright notices. This removes nearly 3000 lines of boilerplate from the project (only python files), which no developer cares to look at. SPDX is in common use, particularly in the Linux kernel, and is the recommended format for Meson's own `project(license: )` field
2023-08-11treewide: automatic rewriting of all comment-style type annotationsEli Schwartz
Performed using https://github.com/ilevkivskyi/com2ann This has no actual effect on the codebase as type checkers (still) support both and negligible effect on runtime performance since __future__ annotations ameliorates that. Technically, the bytecode would be bigger for non function-local annotations, of which we have many either way. So if it doesn't really matter, why do a large-scale refactor? Simple: because people keep wanting to, but it's getting nickle-and-dimed. If we're going to do this we might as well do it consistently in one shot, using tooling that guarantees repeatability and correctness. Repeat with: ``` com2ann mesonbuild/ ```
2023-08-11remove useless type annotationsEli Schwartz
These annotations all had a default initializer of the correct type, or a parent class annotation.
2023-06-26linkers: delay implementations import until detect is runEli Schwartz
This saves on a 1500-line import at startup and may be skipped entirely if no compiled languages are used. In exchange, we move the implementation to a new file that is imported instead. Followup to commit ab20eb5bbc21ae855bcd211131132d2778602bcf.
2023-04-11fix various spelling issuesJosh Soref
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-02-01treewide: add future annotations importEli Schwartz
2022-12-13Revert "openbsd: execinfo is not a compiler lib"Brad Smith
OpenBSD now has execinfo as compiler lib. DragonFly has all along. This reverts commit 0241948d8fa37f59eb93088a26e9b7ae642cc2d0.
2022-10-03pylint: enable unnecessary-dunder-callDylan Baker
2022-09-19pylint: enable use-list-literalDylan Baker
2022-09-12arglist: use typing.MutableSequence instead of collectionsDylan Baker
In the long run collections is the right thing to use, but until we can require 3.9.x as the minimum we cannot annotate the collections.abc version, only the typing version. This allows correct type annotations in users of `CompilerArgs`, as mypy (and friends) can determine that `CompilerArgs` is ~= `T.Sequence[str]`
2021-10-10Fix typos discovered by codespellChristian Clauss
2021-03-04mass rewrite of string formatting to use f-strings everywhereEli Schwartz
performed by running "pyupgrade --py36-plus" and committing the results
2021-01-13Fix misspellsAntonin Décimo
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2020-09-08typing: fix code reviewDaniel Mensinger
2020-09-08typing: get rid of most T.castDaniel Mensinger
2020-09-08typing: fully annotate arglistDaniel Mensinger
2020-08-18arglist: optimize flush_pre_postPaolo Bonzini
pre_flush_set and post_flush_set are almost always empty, so we can use extend() instead of a for...in loop to add the previous elements of self._container. We can also skip the conversion from deque to list since pre_flush is always appended on the right side. On a QEMU build the time spent in flush_pre_post goes from 1.4 to 0.5 seconds.
2020-06-22arglist: Fix remaining mypy errors and warningsDylan Baker
So we can lint it with mypy
2020-06-22arglist: Split the C/C++ specifics parts into a subclass for CLikeDylan Baker
This means that we don't need work arounds for D-like compilers, as the special c-like hanlding wont be used for D compilers.
2020-06-22compilers: Return CompilerArgs from compiler instanceDylan Baker
Since the CompileArgs class already needs to know about the compiler, and we really need at least per-lanaguage if not per-compiler CompilerArgs classes, let's get the CompilerArgs instance from the compiler using a method.
2020-06-22compilers: Split CompilerArgs into a separate moduleDylan Baker
I've also moved this out of the compilers pacakge because we're soon going to need it in linkers, and that creates some serious spagetti