Mercurial > cpython-lru_cache-weakref
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 17996:5a9debb14440 | 17997:27f2422ea335 |
|---|---|
| 78 char *fname = NULL; | 78 char *fname = NULL; |
| 79 char *message = NULL; | 79 char *message = NULL; |
| 80 int min = -1; | 80 int min = -1; |
| 81 int max = 0; | 81 int max = 0; |
| 82 int level = 0; | 82 int level = 0; |
| 83 int endfmt = 0; | |
| 83 char *formatsave = format; | 84 char *formatsave = format; |
| 84 int i, len; | 85 int i, len; |
| 85 char *msg; | 86 char *msg; |
| 86 | 87 |
| 87 assert(compat || (args != (PyObject*)NULL)); | 88 assert(compat || (args != (PyObject*)NULL)); |
| 88 | 89 |
| 89 for (;;) { | 90 while (endfmt == 0) { |
| 90 int c = *format++; | 91 int c = *format++; |
| 91 if (c == '(' /* ')' */) { | 92 switch (c) { |
| 93 case '(': | |
| 92 if (level == 0) | 94 if (level == 0) |
| 93 max++; | 95 max++; |
| 94 level++; | 96 level++; |
| 95 } | 97 break; |
| 96 else if (/* '(' */ c == ')') { | 98 case ')': |
| 97 if (level == 0) | 99 if (level == 0) |
| 98 Py_FatalError(/* '(' */ | 100 Py_FatalError("excess ')' in getargs format"); |
| 99 "excess ')' in getargs format"); | |
| 100 else | 101 else |
| 101 level--; | 102 level--; |
| 102 } | 103 break; |
| 103 else if (c == '\0') | 104 case '\0': |
| 104 break; | 105 endfmt = 1; |
| 105 else if (c == ':') { | 106 break; |
| 107 case ':': | |
| 106 fname = format; | 108 fname = format; |
| 107 break; | 109 endfmt = 1; |
| 108 } | 110 break; |
| 109 else if (c == ';') { | 111 case ';': |
| 110 message = format; | 112 message = format; |
| 111 break; | 113 endfmt = 1; |
| 112 } | 114 break; |
| 113 else if (level != 0) | 115 default: |
| 114 ; /* Pass */ | 116 if (level == 0) { |
| 115 else if (c == 'e') | 117 if (c == 'O') |
| 116 ; /* Pass */ | 118 max++; |
| 117 else if (isalpha(c)) | 119 else if (isalpha(c)) { |
| 118 max++; | 120 if (c != 'e') /* skip encoded */ |
| 119 else if (c == '|') | 121 max++; |
| 120 min = max; | 122 } else if (c == '|') |
| 123 min = max; | |
| 124 } | |
| 125 break; | |
| 126 } | |
| 121 } | 127 } |
| 122 | 128 |
| 123 if (level != 0) | 129 if (level != 0) |
| 124 Py_FatalError(/* '(' */ "missing ')' in getargs format"); | 130 Py_FatalError(/* '(' */ "missing ')' in getargs format"); |
| 125 | 131 |
