changeset 30111:a989fa78dafa

osutil: use PyLongObject on Python 3 for listdir_slot This code looks performance sensitive. So let's retain PyIntObject on Python 2 and use PyLongObject explicitly on Python 3.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 09 Oct 2016 13:47:46 +0200
parents 79f438f5dd02
children 9b6ff0f940ed
files mercurial/osutil.c
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/osutil.c	Sun Oct 09 13:41:18 2016 +0200
+++ b/mercurial/osutil.c	Sun Oct 09 13:47:46 2016 +0200
@@ -63,11 +63,19 @@
 };
 #endif
 
+#ifdef IS_PY3K
+#define listdir_slot(name) \
+	static PyObject *listdir_stat_##name(PyObject *self, void *x) \
+	{ \
+		return PyLong_FromLong(((struct listdir_stat *)self)->st.name); \
+	}
+#else
 #define listdir_slot(name) \
 	static PyObject *listdir_stat_##name(PyObject *self, void *x) \
 	{ \
 		return PyInt_FromLong(((struct listdir_stat *)self)->st.name); \
 	}
+#endif
 
 listdir_slot(st_dev)
 listdir_slot(st_mode)