Skip to content

Commit

Permalink
arglist: post is only appended to, make it a list
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bonzini committed Jan 31, 2025
1 parent 31dce5f commit 8389284
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mesonbuild/arglist.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __init__(self, compiler: T.Union['Compiler', 'StaticLinker'],
self._container: T.List[str] = list(iterable) if iterable is not None else []

self.pre: T.Deque[str] = collections.deque()
self.post: T.Deque[str] = collections.deque()
self.post: T.List[str] = []
self.needs_override_check: bool = False

# Flush the saved pre and post list into the _container list
Expand Down

0 comments on commit 8389284

Please sign in to comment.