From: Enji Cooper Date: Fri, 27 Mar 2020 03:42:40 +0000 (-0700) Subject: Iterate over `tokens` with a for instead of while X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7f115c17c0b4b7a3cdd3e07a24f933c8ab881b52;p=libevent Iterate over `tokens` with a for instead of while This simplifies the logic and avoids unnecessary copying/slicing of array elements in `tokens`. Signed-off-by: Enji Cooper --- diff --git a/event_rpcgen.py b/event_rpcgen.py index 5b59c0db..14138836 100755 --- a/event_rpcgen.py +++ b/event_rpcgen.py @@ -1309,6 +1309,11 @@ def NormalizeLine(line): return line + +NAME_RE = re.compile(r"(?P[^\[\]]+)(\[(?P.*)\])?") +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