]> granicus.if.org Git - libevent/commitdiff
Iterate over `tokens` with a for instead of while
authorEnji Cooper <yaneurabeya@gmail.com>
Fri, 27 Mar 2020 03:42:40 +0000 (20:42 -0700)
committerEnji Cooper <yaneurabeya@gmail.com>
Fri, 27 Mar 2020 17:35:46 +0000 (10:35 -0700)
This simplifies the logic and avoids unnecessary copying/slicing of
array elements in `tokens`.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
event_rpcgen.py

index 5b59c0db5b4ba955750fe43c10dac221c5ff929a..14138836e4646e944581fcaf6f3bd9c5ac8fd418 100755 (executable)
@@ -1309,6 +1309,11 @@ def NormalizeLine(line):
 
     return line
 
+
+NAME_RE = re.compile(r"(?P<name>[^\[\]]+)(\[(?P<fixed_length>.*)\])?")
+TAG_NUMBER_RE = re.compile(r"(0x)?\d+", re.I)
+
+
 def ProcessOneEntry(factory, newstruct, entry):
     optional = 0
     array = 0
@@ -1319,11 +1324,7 @@ def ProcessOneEntry(factory, newstruct, entry):
     separator = ''
     fixed_length = ''
 
-    tokens = entry.split(' ')
-    while tokens:
-        token = tokens[0]
-        tokens = tokens[1:]
-
+    for token in entry.split(" "):
         if not entry_type:
             if not optional and token == 'optional':
                 optional = 1