Generate richcompare switch statements in sorted order
This commit is contained in:
parent
77b08daca7
commit
e147f2af69
1 changed files with 4 additions and 2 deletions
|
|
@ -4073,14 +4073,16 @@ public:
|
|||
Printf(f, " PyTuple_SET_ITEM(tuple, 0, other);\n");
|
||||
Printf(f, " Py_XINCREF(other);\n");
|
||||
}
|
||||
Iterator rich_iter = First(richcompare);
|
||||
List *richcompare_list = SortedKeys(richcompare, 0);
|
||||
Iterator rich_iter = First(richcompare_list);
|
||||
if (rich_iter.item) {
|
||||
Printf(f, " switch (op) {\n");
|
||||
for (; rich_iter.item; rich_iter = Next(rich_iter))
|
||||
Printf(f, " case %s : result = %s(self, %s); break;\n", rich_iter.key, rich_iter.item, funpack ? "other" : "tuple");
|
||||
Printf(f, " case %s : result = %s(self, %s); break;\n", rich_iter.item, Getattr(richcompare, rich_iter.item), funpack ? "other" : "tuple");
|
||||
Printv(f, " default : break;\n", NIL);
|
||||
Printf(f, " }\n");
|
||||
}
|
||||
Delete(richcompare_list);
|
||||
Printv(f, " if (!result) {\n", NIL);
|
||||
Printv(f, " if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) {\n", NIL);
|
||||
Printv(f, " result = SwigPyObject_richcompare((SwigPyObject *)self, (SwigPyObject *)other, op);\n", NIL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue