Skip to content

Commit 95f9403

Browse files
committed
cleanup
1 parent d92f4ea commit 95f9403

File tree

1 file changed

+2
-64
lines changed

1 file changed

+2
-64
lines changed

src/auto_map.c

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -396,52 +396,6 @@ string_to_hash(char *str, Py_ssize_t len) {
396396
return hash;
397397
}
398398

399-
//------------------------------------------------------------------------------
400-
// the global int_cache is shared among all instances
401-
402-
// static PyObject *int_cache = NULL;
403-
404-
// // NOTE: this used to be a Py_ssize_t, which can be 32 bits on some machines and might easily overflow with a few very large indices. Using an explicit 64-bit int seems safer
405-
// static npy_int64 key_count_global = 0;
406-
407-
// // Fill the int_cache up to size_needed with PyObject ints; `size` is not the key_count_global.
408-
// static int
409-
// int_cache_fill(Py_ssize_t size_needed)
410-
// {
411-
// PyObject *item;
412-
// if (!int_cache) {
413-
// int_cache = PyList_New(0);
414-
// if (!int_cache) {
415-
// return -1;
416-
// }
417-
// }
418-
// for (Py_ssize_t i = PyList_GET_SIZE(int_cache); i < size_needed; i++) {
419-
// item = PyLong_FromSsize_t(i);
420-
// if (!item) {
421-
// return -1;
422-
// }
423-
// if (PyList_Append(int_cache, item)) {
424-
// Py_DECREF(item);
425-
// return -1;
426-
// }
427-
// Py_DECREF(item);
428-
// }
429-
// return 0;
430-
// }
431-
432-
// // Given the current key_count_global, remove cache elements only if the key_count is less than the the current size of the int_cache.
433-
// void
434-
// int_cache_remove(Py_ssize_t key_count)
435-
// {
436-
// if (!key_count) {
437-
// Py_CLEAR(int_cache);
438-
// }
439-
// else if (key_count < PyList_GET_SIZE(int_cache)) {
440-
// // del int_cache[key_count:]
441-
// PyList_SetSlice(int_cache, key_count, PyList_GET_SIZE(int_cache), NULL);
442-
// }
443-
// }
444-
445399
//------------------------------------------------------------------------------
446400
// FrozenAutoMapIterator functions
447401

@@ -468,7 +422,7 @@ fami_iter(FAMIObject *self)
468422
return self;
469423
}
470424

471-
// For a FAMI, Return appropriate PyObject for items, keys, and values. When values are needed they are retrieved from the int_cache. For consistency with NumPy array iteration, arrays use PyArray_ToScalar instead of PyArray_GETITEM.
425+
// For a FAMI, Return appropriate PyObject for items, keys, and values. For consistency with NumPy array iteration, arrays use PyArray_ToScalar instead of PyArray_GETITEM.
472426
static PyObject *
473427
fami_iternext(FAMIObject *self)
474428
{
@@ -1556,10 +1510,6 @@ insert_string(
15561510
static int
15571511
grow_table(FAMObject *self, Py_ssize_t keys_size)
15581512
{
1559-
// NOTE: this is the only place int_cache_fill is called; it is not called with key_count_global, but with the max value needed
1560-
// if (int_cache_fill(keys_size)) {
1561-
// return -1;
1562-
// }
15631513
Py_ssize_t keys_load = keys_size / LOAD;
15641514
Py_ssize_t size_old = self->table_size;
15651515
if (keys_load < size_old) {
@@ -1628,8 +1578,6 @@ copy_to_new(PyTypeObject *cls, FAMObject *self, FAMObject *new)
16281578
return -1;
16291579
}
16301580
}
1631-
// key_count_global += self->keys_size;
1632-
16331581
new->table_size = self->table_size;
16341582
new->keys_array_type = self->keys_array_type;
16351583
new->keys_size = self->keys_size;
@@ -1691,7 +1639,6 @@ extend(FAMObject *self, PyObject *keys)
16911639
return -1;
16921640
}
16931641
Py_ssize_t size_extend = PySequence_Fast_GET_SIZE(keys);
1694-
// key_count_global += size_extend;
16951642
self->keys_size += size_extend;
16961643

16971644
if (grow_table(self, self->keys_size)) {
@@ -1723,7 +1670,6 @@ append(FAMObject *self, PyObject *key)
17231670
PyErr_SetString(PyExc_NotImplementedError, "Not supported for array keys");
17241671
return -1;
17251672
}
1726-
// key_count_global++;
17271673
self->keys_size++;
17281674

17291675
if (grow_table(self, self->keys_size)) {
@@ -1746,7 +1692,7 @@ fam_length(FAMObject *self)
17461692
}
17471693

17481694

1749-
// Given a key for a FAM, return the Python integer (via the int_cache) associated with that key. Utility function used in both fam_subscript() and fam_get()
1695+
// Given a key for a FAM, return the Python integer associated with that key. Utility function used in both fam_subscript() and fam_get()
17501696
static PyObject *
17511697
get(FAMObject *self, PyObject *key, PyObject *missing) {
17521698
Py_ssize_t keys_pos = lookup(self, key);
@@ -1762,9 +1708,6 @@ get(FAMObject *self, PyObject *key, PyObject *missing) {
17621708
return NULL;
17631709
}
17641710
return PyLong_FromSsize_t(keys_pos);
1765-
// PyObject *index = PyList_GET_ITEM(int_cache, keys_pos);
1766-
// Py_INCREF(index);
1767-
// return index;
17681711
}
17691712

17701713

@@ -2238,11 +2181,7 @@ fam_dealloc(FAMObject *self)
22382181
if (self->keys) {
22392182
Py_DECREF(self->keys);
22402183
}
2241-
2242-
// key_count_global -= self->keys_size;
2243-
22442184
Py_TYPE(self)->tp_free((PyObject *)self);
2245-
// int_cache_remove(key_count_global);
22462185
}
22472186

22482187

@@ -2490,7 +2429,6 @@ fam_init(PyObject *self, PyObject *args, PyObject *kwargs)
24902429
fam->keys_array_type = keys_array_type;
24912430
fam->keys_size = keys_size;
24922431
fam->key_buffer = NULL;
2493-
// key_count_global += keys_size;
24942432

24952433
// NOTE: on itialization, grow_table() does not use keys
24962434
if (grow_table(fam, keys_size)) {

0 commit comments

Comments
 (0)