Mercurial > cpython-lru_cache-weakref
diff Python/getargs.c @ 17997:27f2422ea335 legacy-trunk
Change cascaded if stmts to switch stmt in vgetargs1().
In the default branch, keep three ifs that are used if level == 0, the
most common case. Note that first if here is a slight optimization
for the 'O' format.
Second part of SF patch 426072.
| author | Jeremy Hylton <jeremy@alum.mit.edu> |
|---|---|
| date | Tue, 29 May 2001 17:46:19 +0000 |
| parents | 5a9debb14440 |
| children | 9b291ca6546c |
line wrap: on
line diff
--- a/Python/getargs.c Tue May 29 17:37:05 2001 +0000 +++ b/Python/getargs.c Tue May 29 17:46:19 2001 +0000 @@ -80,44 +80,50 @@ int min = -1; int max = 0; int level = 0; + int endfmt = 0; char *formatsave = format; int i, len; char *msg; assert(compat || (args != (PyObject*)NULL)); - for (;;) { + while (endfmt == 0) { int c = *format++; - if (c == '(' /* ')' */) { + switch (c) { + case '(': if (level == 0) max++; level++; - } - else if (/* '(' */ c == ')') { + break; + case ')': if (level == 0) - Py_FatalError(/* '(' */ - "excess ')' in getargs format"); + Py_FatalError("excess ')' in getargs format"); else level--; - } - else if (c == '\0') + break; + case '\0': + endfmt = 1; + break; + case ':': + fname = format; + endfmt = 1; break; - else if (c == ':') { - fname = format; + case ';': + message = format; + endfmt = 1; + break; + default: + if (level == 0) { + if (c == 'O') + max++; + else if (isalpha(c)) { + if (c != 'e') /* skip encoded */ + max++; + } else if (c == '|') + min = max; + } break; } - else if (c == ';') { - message = format; - break; - } - else if (level != 0) - ; /* Pass */ - else if (c == 'e') - ; /* Pass */ - else if (isalpha(c)) - max++; - else if (c == '|') - min = max; } if (level != 0)
