Anonymous avatar Anonymous committed 3413421

patchedast: using collections.deque when list.(insert|pop)(0) is used

Comments (0)

Files changed (1)


+import collections
 import re
 import warnings
                 'Node <%s> has been already patched; please report!' %
                 node.__class__.__name__, RuntimeWarning)
+        base_children = collections.deque(base_children)
-        children = []
+        children = collections.deque()
         formats = []
         suspected_start = self.source.offset
         start = suspected_start
         first_token = True
         while base_children:
-            child = base_children.pop(0)
+            child = base_children.popleft()
             if child is None:
             offset = self.source.offset
             start = self._eat_surrounding_parens(
                 children, suspected_start, start)
         if eat_spaces:
-            children.insert(0, self.source[0:start])
+            children.appendleft(self.source[0:start])
             end_spaces = self.source[self.source.offset:]
         for i in range(opens):
             new_start = self.source.rfind_token('(', 0, new_start)
         if new_start != start:
-            children.insert(0, self.source.get(new_start, start))
+            children.appendleft(self.source.get(new_start, start))
             start = new_start
         return start
             old_start = start
             old_offset = self.source.offset
             start = index
-            children.insert(0, '(')
-            children.insert(1, self.source[start + 1:old_start])
+            children.appendleft(self.source[start + 1:old_start])
+            children.appendleft('(')
             token_start, token_end = self.source.consume(')')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.