Anonymous avatar Anonymous committed 805f418

Use Py_ssize_t

Comments (0)

Files changed (2)

Include/setobject.h

 struct _setobject {
 	PyObject_HEAD
 
-	int fill;  /* # Active + # Dummy */
-	int used;  /* # Active */
+	Py_ssize_t fill;  /* # Active + # Dummy */
+	Py_ssize_t used;  /* # Active */
 
 	/* The table contains mask + 1 slots, and that's a power of 2.
 	 * We store the mask instead of the size because the mask is more
 	 * frequently needed.
 	 */
-	int mask;
+	Py_ssize_t mask;
 
 	/* table points to smalltable for small tables, else to
 	 * additional malloc'ed memory.  table is never NULL!  This rule

Objects/setobject.c

 	register Py_ssize_t i;
 	register size_t perturb;
 	register setentry *freeslot;
-	register unsigned int mask = so->mask;
+	register size_t mask = so->mask;
 	setentry *table = so->table;
 	register setentry *entry;
 	register int cmp;
 	register Py_ssize_t i;
 	register size_t perturb;
 	register setentry *freeslot;
-	register unsigned int mask = so->mask;
+	register size_t mask = so->mask;
 	setentry *table = so->table;
 	register setentry *entry;
 
 actually be smaller than the old one.
 */
 static int
-set_table_resize(PySetObject *so, int minused)
+set_table_resize(PySetObject *so, Py_ssize_t minused)
 {
-	int newsize;
+	Py_ssize_t newsize;
 	setentry *oldtable, *newtable, *entry;
-	int i;
+	Py_ssize_t i;
 	int is_oldtable_malloced;
 	setentry small_copy[PySet_MINSIZE];
 
 static int
 set_add_entry(register PySetObject *so, setentry *entry)
 {
-	register int n_used;
+	register Py_ssize_t n_used;
 
 	assert(so->fill <= so->mask);  /* at least one empty slot */
 	n_used = so->used;
 set_add_key(register PySetObject *so, PyObject *key)
 {
 	register long hash;
-	register int n_used;
+	register Py_ssize_t n_used;
 
 	if (!PyString_CheckExact(key) ||
 	    (hash = ((PyStringObject *) key)->ob_shash) == -1) {
 {
 	setentry *entry, *table;
 	int table_is_malloced;
-	int fill;
+	Py_ssize_t fill;
 	setentry small_copy[PySet_MINSIZE];
 #ifdef Py_DEBUG
-	int i, n;
+	Py_ssize_t i, n;
 	assert (PyAnySet_Check(so));
 
 	n = so->mask + 1;
 /*
  * Iterate over a set table.  Use like so:
  *
- *     int pos;
+ *     Py_ssize_t pos;
  *     setentry *entry;
  *     pos = 0;   # important!  pos should not otherwise be changed by you
  *     while (set_next(yourset, &pos, &entry)) {
 set_next(PySetObject *so, Py_ssize_t *pos_ptr, setentry **entry_ptr)
 {
 	Py_ssize_t i;
-	int mask;
+	Py_ssize_t mask;
 	register setentry *table;
 
 	assert (PyAnySet_Check(so));
 set_dealloc(PySetObject *so)
 {
 	register setentry *entry;
-	int fill = so->fill;
+	Py_ssize_t fill = so->fill;
 	PyObject_GC_UnTrack(so);
 	Py_TRASHCAN_SAFE_BEGIN(so)
 	if (so->weakreflist != NULL)
 set_merge(PySetObject *so, PyObject *otherset)
 {
 	PySetObject *other;
-	register int i;
+	register Py_ssize_t i;
 	register setentry *entry;
 
 	assert (PyAnySet_Check(so));
 static PyObject *
 set_pop(PySetObject *so)
 {
-	register int i = 0;
+	register Py_ssize_t i = 0;
 	register setentry *entry;
 	PyObject *key;
 
 	 */
 	entry = &so->table[0];
 	if (entry->key == NULL || entry->key == dummy) {
-		i = (int)entry->hash;
+		i = entry->hash;
 		/* The hash field may be a real hash value, or it may be a
 		 * legit search finger, or it may be a once-legit search
 		 * finger that's out of bounds now because it wrapped around
 typedef struct {
 	PyObject_HEAD
 	PySetObject *si_set; /* Set to NULL when iterator is exhausted */
-	int si_used;
-	int si_pos;
-	long len;
+	Py_ssize_t si_used;
+	Py_ssize_t si_pos;
+	Py_ssize_t len;
 } setiterobject;
 
 static void
 static PyObject *
 setiter_len(setiterobject *si)
 {
-	long len = 0;
+	Py_ssize_t len = 0;
 	if (si->si_set != NULL && si->si_used == si->si_set->used)
 		len = si->len;
 	return PyInt_FromLong(len);
 static PyObject *setiter_iternext(setiterobject *si)
 {
 	PyObject *key;
-	register int i, mask;
+	register Py_ssize_t i, mask;
 	register setentry *entry;
 	PySetObject *so = si->si_set;
 
 static void
 set_swap_bodies(PySetObject *a, PySetObject *b)
 {
-	int t;
+	Py_ssize_t t;
 	setentry *u;
 	setentry *(*f)(PySetObject *so, PyObject *key, long hash);
 	setentry tab[PySet_MINSIZE];
 static PyObject *
 test_c_api(PySetObject *so)
 {
-	int count;
+	Py_ssize_t count;
 	char *s;
 	Py_ssize_t i;
 	PyObject *elem, *dup, *t, *f, *dup2;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.