Mercurial > hg
comparison mercurial/osutil.c @ 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 | 0852161588c6 |
comparison
equal
deleted
inserted
replaced
30110:79f438f5dd02 | 30111:a989fa78dafa |
---|---|
61 PyObject_HEAD | 61 PyObject_HEAD |
62 struct stat st; | 62 struct stat st; |
63 }; | 63 }; |
64 #endif | 64 #endif |
65 | 65 |
66 #ifdef IS_PY3K | |
67 #define listdir_slot(name) \ | |
68 static PyObject *listdir_stat_##name(PyObject *self, void *x) \ | |
69 { \ | |
70 return PyLong_FromLong(((struct listdir_stat *)self)->st.name); \ | |
71 } | |
72 #else | |
66 #define listdir_slot(name) \ | 73 #define listdir_slot(name) \ |
67 static PyObject *listdir_stat_##name(PyObject *self, void *x) \ | 74 static PyObject *listdir_stat_##name(PyObject *self, void *x) \ |
68 { \ | 75 { \ |
69 return PyInt_FromLong(((struct listdir_stat *)self)->st.name); \ | 76 return PyInt_FromLong(((struct listdir_stat *)self)->st.name); \ |
70 } | 77 } |
78 #endif | |
71 | 79 |
72 listdir_slot(st_dev) | 80 listdir_slot(st_dev) |
73 listdir_slot(st_mode) | 81 listdir_slot(st_mode) |
74 listdir_slot(st_nlink) | 82 listdir_slot(st_nlink) |
75 #ifdef _WIN32 | 83 #ifdef _WIN32 |