Lines Matching refs:mp
150 lookdict_string(PyDictObject *mp, PyObject *key, long hash);
210 #define INIT_NONZERO_DICT_SLOTS(mp) do { \
211 (mp)->ma_table = (mp)->ma_smalltable; \
212 (mp)->ma_mask = PyDict_MINSIZE - 1; \
215 #define EMPTY_TO_MINSIZE(mp) do { \
216 memset((mp)->ma_smalltable, 0, sizeof((mp)->ma_smalltable)); \
217 (mp)->ma_used = (mp)->ma_fill = 0; \
218 INIT_NONZERO_DICT_SLOTS(mp); \
243 register PyDictObject *mp;
259 mp = free_list[--numfree];
260 assert (mp != NULL);
261 assert (Py_TYPE(mp) == &PyDict_Type);
262 _Py_NewReference((PyObject *)mp);
263 if (mp->ma_fill) {
264 EMPTY_TO_MINSIZE(mp);
268 INIT_NONZERO_DICT_SLOTS(mp);
270 assert (mp->ma_used == 0);
271 assert (mp->ma_table == mp->ma_smalltable);
272 assert (mp->ma_mask == PyDict_MINSIZE - 1);
277 mp = PyObject_GC_New(PyDictObject, &PyDict_Type);
278 if (mp == NULL)
280 EMPTY_TO_MINSIZE(mp);
285 mp->ma_lookup = lookdict_string;
292 return (PyObject *)mp;
320 lookdict(PyDictObject *mp, PyObject *key, register long hash)
325 register size_t mask = (size_t)mp->ma_mask;
326 PyDictEntry *ep0 = mp->ma_table;
346 if (ep0 == mp->ma_table && ep->me_key == startkey) {
356 return lookdict(mp, key, hash);
378 if (ep0 == mp->ma_table && ep->me_key == startkey) {
388 return lookdict(mp, key, hash);
408 lookdict_string(PyDictObject *mp, PyObject *key, register long hash)
413 register size_t mask = (size_t)mp->ma_mask;
414 PyDictEntry *ep0 = mp->ma_table;
425 mp->ma_lookup = lookdict;
426 return lookdict(mp, key, hash);
469 #define MAINTAIN_TRACKING(mp, key, value) \
471 if (!_PyObject_GC_IS_TRACKED(mp)) { \
474 _PyObject_GC_TRACK(mp); \
483 PyDictObject *mp;
491 mp = (PyDictObject *) op;
492 ep = mp->ma_table;
493 mask = mp->ma_mask;
510 insertdict_by_entry(register PyDictObject *mp, PyObject *key, long hash,
515 MAINTAIN_TRACKING(mp, key, value);
524 mp->ma_fill++;
532 mp->ma_used++;
545 insertdict(register PyDictObject *mp, PyObject *key, long hash, PyObject *value)
549 assert(mp->ma_lookup != NULL);
550 ep = mp->ma_lookup(mp, key, hash);
556 return insertdict_by_entry(mp, key, hash, ep, value);
568 insertdict_clean(register PyDictObject *mp, PyObject *key, long hash,
573 register size_t mask = (size_t)mp->ma_mask;
574 PyDictEntry *ep0 = mp->ma_table;
577 MAINTAIN_TRACKING(mp, key, value);
585 mp->ma_fill++;
589 mp->ma_used++;
598 dictresize(PyDictObject *mp, Py_ssize_t minused)
619 oldtable = mp->ma_table;
621 is_oldtable_malloced = oldtable != mp->ma_smalltable;
625 newtable = mp->ma_smalltable;
627 if (mp->ma_fill == mp->ma_used) {
637 assert(mp->ma_fill > mp->ma_used);
652 mp->ma_table = newtable;
653 mp->ma_mask = newsize - 1;
655 mp->ma_used = 0;
656 i = mp->ma_fill;
657 mp->ma_fill = 0;
664 insertdict_clean(mp, ep->me_key, (long)ep->me_hash,
711 PyDictObject *mp = (PyDictObject *)op;
736 ep = (mp->ma_lookup)(mp, key, hash);
743 ep = (mp->ma_lookup)(mp, key, hash);
760 PyDictObject *mp = (PyDictObject *)op;
775 ep = (mp->ma_lookup)(mp, key, hash);
786 register PyDictObject *mp;
789 mp = (PyDictObject *)op;
790 assert(mp->ma_fill <= mp->ma_mask); /* at least one empty slot */
791 n_used = mp->ma_used;
795 if (insertdict(mp, key, hash, value) != 0)
799 if (insertdict_by_entry(mp, key, hash, ep, value) != 0)
816 if (!(mp->ma_used > n_used && mp->ma_fill*3 >= (mp->ma_mask+1)*2))
818 return dictresize(mp, (mp->ma_used > 50000 ? 2 : 4) * mp->ma_used);
852 delitem_common(PyDictObject *mp, PyDictEntry *ep)
861 mp->ma_used--;
870 register PyDictObject *mp;
885 mp = (PyDictObject *)op;
886 ep = (mp->ma_lookup)(mp, key, hash);
894 return delitem_common(mp, ep);
901 register PyDictObject *mp;
917 mp = (PyDictObject *)op;
918 ep = (mp->ma_lookup)(mp, key, hash);
929 return delitem_common(mp, ep);
937 PyDictObject *mp;
948 mp = (PyDictObject *)op;
950 n = mp->ma_mask + 1;
954 table = mp->ma_table;
956 table_is_malloced = table != mp->ma_smalltable;
961 * clearing the slots, and never refer to anything via mp->xxx while
964 fill = mp->ma_fill;
966 EMPTY_TO_MINSIZE(mp);
975 EMPTY_TO_MINSIZE(mp);
1075 dict_dealloc(register PyDictObject *mp)
1078 Py_ssize_t fill = mp->ma_fill;
1080 PyObject_GC_UnTrack(mp);
1081 Py_TRASHCAN_SAFE_BEGIN(mp)
1082 for (ep = mp->ma_table; fill > 0; ep++) {
1089 if (mp->ma_table != mp->ma_smalltable)
1090 PyMem_DEL(mp->ma_table);
1091 if (numfree < PyDict_MAXFREELIST && Py_TYPE(mp) == &PyDict_Type)
1092 free_list[numfree++] = mp;
1094 Py_TYPE(mp)->tp_free((PyObject *)mp);
1095 Py_TRASHCAN_SAFE_END(mp)
1099 dict_print(register PyDictObject *mp, register FILE *fp, register int flags)
1105 status = Py_ReprEnter((PyObject*)mp);
1119 for (i = 0; i <= mp->ma_mask; i++) {
1120 PyDictEntry *ep = mp->ma_table + i;
1133 Py_ReprLeave((PyObject*)mp);
1141 Py_ReprLeave((PyObject*)mp);
1150 Py_ReprLeave((PyObject*)mp);
1155 dict_repr(PyDictObject *mp)
1162 i = Py_ReprEnter((PyObject *)mp);
1167 if (mp->ma_used == 0) {
1183 while (PyDict_Next((PyObject *)mp, &i, &key, &value)) {
1229 Py_ReprLeave((PyObject *)mp);
1234 dict_length(PyDictObject *mp)
1236 return mp->ma_used;
1240 dict_subscript(PyDictObject *mp, register PyObject *key)
1245 assert(mp->ma_table != NULL);
1252 ep = (mp->ma_lookup)(mp, key, hash);
1257 if (!PyDict_CheckExact(mp)) {
1261 missing = _PyObject_LookupSpecial((PyObject *)mp,
1282 dict_ass_sub(PyDictObject *mp, PyObject *v, PyObject *w)
1285 return PyDict_DelItem((PyObject *)mp, v);
1287 return PyDict_SetItem((PyObject *)mp, v, w);
1297 dict_keys(register PyDictObject *mp)
1305 n = mp->ma_used;
1309 if (n != mp->ma_used) {
1316 ep = mp->ma_table;
1317 mask = mp->ma_mask;
1331 dict_values(register PyDictObject *mp)
1339 n = mp->ma_used;
1343 if (n != mp->ma_used) {
1350 ep = mp->ma_table;
1351 mask = mp->ma_mask;
1365 dict_items(register PyDictObject *mp)
1378 n = mp->ma_used;
1390 if (n != mp->ma_used) {
1398 ep = mp->ma_table;
1399 mask = mp->ma_mask;
1434 PyDictObject *mp = (PyDictObject *)d;
1440 if (dictresize(mp, ((PyDictObject *)seq)->ma_used / 2 * 3)) {
1448 if (insertdict(mp, key, hash, value)) {
1456 PyDictObject *mp = (PyDictObject *)d;
1461 if (dictresize(mp, PySet_GET_SIZE(seq) / 2 * 3)) {
1469 if (insertdict(mp, key, hash, value)) {
1635 register PyDictObject *mp, *other;
1648 mp = (PyDictObject*)a;
1651 if (other == mp || other->ma_used == 0)
1654 if (mp->ma_used == 0)
1664 if ((mp->ma_fill + other->ma_used)*3 >= (mp->ma_mask+1)*2) {
1665 if (dictresize(mp, (mp->ma_used + other->ma_used)*2) != 0)
1675 if (insertdict(mp, entry->me_key,
1730 dict_copy(register PyDictObject *mp)
1732 return PyDict_Copy((PyObject*)mp);
1754 PyDict_Size(PyObject *mp)
1756 if (mp == NULL || !PyDict_Check(mp)) {
1760 return ((PyDictObject *)mp)->ma_used;
1764 PyDict_Keys(PyObject *mp)
1766 if (mp == NULL || !PyDict_Check(mp)) {
1770 return dict_keys((PyDictObject *)mp);
1774 PyDict_Values(PyObject *mp)
1776 if (mp == NULL || !PyDict_Check(mp)) {
1780 return dict_values((PyDictObject *)mp);
1784 PyDict_Items(PyObject *mp)
1786 if (mp == NULL || !PyDict_Check(mp)) {
1790 return dict_items((PyDictObject *)mp);
1992 dict_contains(register PyDictObject *mp, PyObject *key)
2003 ep = (mp->ma_lookup)(mp, key, hash);
2010 dict_has_key(register PyDictObject *mp, PyObject *key)
2015 return dict_contains(mp, key);
2019 dict_get(register PyDictObject *mp, PyObject *args)
2036 ep = (mp->ma_lookup)(mp, key, hash);
2048 dict_setdefault(register PyDictObject *mp, PyObject *args)
2065 ep = (mp->ma_lookup)(mp, key, hash);
2070 if (dict_set_item_by_hash_or_entry((PyObject*)mp, key, hash, ep,
2080 dict_clear(register PyDictObject *mp)
2082 PyDict_Clear((PyObject *)mp);
2087 dict_pop(PyDictObject *mp, PyObject *args)
2096 if (mp->ma_used == 0) {
2110 ep = (mp->ma_lookup)(mp, key, hash);
2126 mp->ma_used--;
2132 dict_popitem(PyDictObject *mp)
2150 if (mp->ma_used == 0) {
2162 ep = &mp->ma_table[0];
2170 if (i > mp->ma_mask || i < 1)
2172 while ((ep = &mp->ma_table[i])->me_value == NULL) {
2174 if (i > mp->ma_mask)
2183 mp->ma_used--;
2184 assert(mp->ma_table[0].me_value == NULL);
2185 mp->ma_table[0].me_hash = i + 1; /* next place to start */
2235 dict_sizeof(PyDictObject *mp)
2239 res = _PyObject_SIZE(Py_TYPE(mp));
2240 if (mp->ma_table != mp->ma_smalltable)
2241 res = res + (mp->ma_mask + 1) * sizeof(PyDictEntry);
2367 PyDictObject *mp = (PyDictObject *)op;
2376 ep = (mp->ma_lookup)(mp, key, hash);
2384 PyDictObject *mp = (PyDictObject *)op;
2387 ep = (mp->ma_lookup)(mp, key, hash);