gh-90861: Memory optimization for set.issubset (gh-92799)

This commit is contained in:
Dong-hee Na 2022-05-14 17:58:19 +09:00 committed by GitHub
parent 9f68dab3d3
commit 2e8f721c0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -1735,13 +1735,13 @@ set_issubset(PySetObject *so, PyObject *other)
int rv; int rv;
if (!PyAnySet_Check(other)) { if (!PyAnySet_Check(other)) {
PyObject *tmp, *result; PyObject *tmp = set_intersection(so, other);
tmp = make_new_set(&PySet_Type, other); if (tmp == NULL) {
if (tmp == NULL)
return NULL; return NULL;
result = set_issubset(so, tmp); }
int result = (PySet_GET_SIZE(tmp) == PySet_GET_SIZE(so));
Py_DECREF(tmp); Py_DECREF(tmp);
return result; return PyBool_FromLong(result);
} }
if (PySet_GET_SIZE(so) > PySet_GET_SIZE(other)) if (PySet_GET_SIZE(so) > PySet_GET_SIZE(other))
Py_RETURN_FALSE; Py_RETURN_FALSE;