Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(38448)

Unified Diff: Modules/_functoolsmodule.c

Issue 14373: C implementation of functools.lru_cache
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Modules/_functoolsmodule.c Tue Jul 14 13:51:40 2015 +1200
+++ b/Modules/_functoolsmodule.c Tue Jul 14 09:22:37 2015 +0300
@@ -899,7 +899,7 @@ bounded_lru_cache_wrapper(lru_cache_obje
static PyObject *
lru_cache_new(PyTypeObject *type, PyObject *args, PyObject *kw)
{
- PyObject *func, *maxsize_O, *cache_info_type;
+ PyObject *func, *maxsize_O, *cache_info_type, *cachedict;
int typed;
lru_cache_object *obj;
Py_ssize_t maxsize;
@@ -937,15 +937,16 @@ lru_cache_new(PyTypeObject *type, PyObje
return NULL;
}
- obj = (lru_cache_object *)type->tp_alloc(type, 0);
- if (obj == NULL)
+ if (!(cachedict = PyDict_New()))
return NULL;
- if (!(obj->cache = PyDict_New())) {
- Py_DECREF(obj);
+ obj = (lru_cache_object *)type->tp_alloc(type, 0);
+ if (obj == NULL) {
+ Py_DECREF(cachedict);
return NULL;
}
+ obj->cache = cachedict;
obj->root.prev = &obj->root;
obj->root.next = &obj->root;
obj->maxsize = maxsize;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+