Skip to content

Commit acdd2d1

Browse files
authored
Optimize C version of getall() (#1212)
1 parent 7129ac3 commit acdd2d1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGES/1212.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C implementation of :class:`multidict.MultiDict.getall` now is slightly faster if it returns nothing -- by :user:`asvetlov`.

multidict/_multilib/hashtable.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,10 @@ md_get_all(MultiDictObject *md, PyObject *key, PyObject **ret)
903903
goto fail;
904904
}
905905

906-
md_finder_cleanup(&finder);
906+
if (*ret != NULL) {
907+
// there is no need to restore hashes if none was marked
908+
md_finder_cleanup(&finder);
909+
}
907910
Py_DECREF(identity);
908911
return *ret != NULL;
909912
fail:

0 commit comments

Comments
 (0)