summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-05-29 17:46:19 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-05-29 17:46:19 (GMT)
commit25916bdc11c7d96ada294a25cff3510ef72ddb75 (patch)
tree437990cec31708a7449604e1cbee1777367c75b9 /Python
parent1cb7aa3e6e0a7cf94938701ac1a027e1b5b25c1f (diff)
downloadcpython-25916bdc11c7d96ada294a25cff3510ef72ddb75.zip
cpython-25916bdc11c7d96ada294a25cff3510ef72ddb75.tar.gz
cpython-25916bdc11c7d96ada294a25cff3510ef72ddb75.tar.bz2
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.
Diffstat (limited to 'Python')
-rw-r--r--Python/getargs.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/Python/getargs.c b/Python/getargs.c
index c112386..8c00b0e 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -80,44 +80,50 @@ vgetargs1(PyObject *args, char *format, va_list *p_va, int compat)
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;
- else if (c == ':') {
+ case '\0':
+ endfmt = 1;
+ break;
+ case ':':
fname = format;
+ endfmt = 1;
break;
- }
- else if (c == ';') {
+ 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 (level != 0)
- ; /* Pass */
- else if (c == 'e')
- ; /* Pass */
- else if (isalpha(c))
- max++;
- else if (c == '|')
- min = max;
}
if (level != 0)