Lines Matching refs:link
743 2). The prev/next link fields use borrowed references.
769 lru_list_elem_dealloc(lru_list_elem *link)
771 PyTypeObject *tp = Py_TYPE(link);
772 Py_XDECREF(link->key);
773 Py_XDECREF(link->result);
774 tp->tp_free(link);
932 lru_cache_extract_link(lru_list_elem *link)
934 lru_list_elem *link_prev = link->prev;
935 lru_list_elem *link_next = link->next;
936 link_prev->next = link->next;
937 link_next->prev = link->prev;
941 lru_cache_append_link(lru_cache_object *self, lru_list_elem *link)
945 last->next = root->prev = link;
946 link->prev = last;
947 link->next = root;
951 lru_cache_prepend_link(lru_cache_object *self, lru_list_elem *link)
955 first->prev = root->next = link;
956 link->prev = root;
957 link->next = first;
994 lru_list_elem *link;
1006 link = (lru_list_elem *)_PyDict_GetItem_KnownHash(self->cache, key, hash);
1007 if (link != NULL) {
1008 lru_cache_extract_link(link);
1009 lru_cache_append_link(self, link);
1010 result = link->result;
1029 during the PyObject_Call(). Since the link update is already
1051 /* Cache is not full, so put the result in a new link */
1052 link = (lru_list_elem *)PyObject_New(lru_list_elem,
1054 if (link == NULL) {
1060 link->hash = hash;
1061 link->key = key;
1062 link->result = result;
1066 with this new link, leaving the old link as an orphan (i.e. not
1068 if (_PyDict_SetItem_KnownHash(self->cache, key, (PyObject *)link,
1070 Py_DECREF(link);
1073 lru_cache_append_link(self, link);
1078 a new key. Rather than free the old link and allocate a new
1079 one, we reuse the link for the new key and result and move it
1083 of the links in place. Either the link is successfully
1086 make sense to reinsert the link, so we leave it out
1093 link = self->root.next;
1094 lru_cache_extract_link(link);
1096 The cache dict holds one reference to the link.
1097 We created one other reference when the link was created.
1099 popresult = _PyDict_Pop_KnownHash(self->cache, link->key,
1100 link->hash, Py_None);
1104 This link is now an orphan. Since we don't want to leave the
1105 cache in an inconsistent state, we don't restore the link. */
1107 Py_DECREF(link);
1113 being evicted) from the cache. We restore the link to its
1114 original position as the oldest link. Then we allow the
1117 lru_cache_prepend_link(self, link);
1126 oldkey = link->key;
1127 oldresult = link->result;
1129 link->hash = hash;
1130 link->key = key;
1131 link->result = result;
1132 /* Note: The link is being added to the cache dict without the
1135 link to the linked list. Otherwise, the potentially reentrant
1136 __eq__ call could cause the then orphan link to be visited. */
1137 if (_PyDict_SetItem_KnownHash(self->cache, key, (PyObject *)link,
1140 restore the old link. Let the error propagate upward and
1141 leave the cache short one link. */
1143 Py_DECREF(link);
1148 lru_cache_append_link(self, link);
1239 lru_list_elem *link = root->next;
1240 if (link == root)
1244 return link;
1248 lru_cache_clear_list(lru_list_elem *link)
1250 while (link != NULL) {
1251 lru_list_elem *next = link->next;
1252 Py_DECREF(link);
1253 link = next;
1349 lru_list_elem *link = self->root.next;
1350 while (link != &self->root) {
1351 lru_list_elem *next = link->next;
1352 Py_VISIT(link->key);
1353 Py_VISIT(link->result);
1354 Py_VISIT(Py_TYPE(link));
1355 link = next;