equal
deleted
inserted
replaced
56 expects (= 2/3), so as soon as we cross the threshold we'll resize |
56 expects (= 2/3), so as soon as we cross the threshold we'll resize |
57 anyway. So create a dictionary that's at least 3/2 the size. */ |
57 anyway. So create a dictionary that's at least 3/2 the size. */ |
58 return _PyDict_NewPresized(((1 + expected_size) / 2) * 3); |
58 return _PyDict_NewPresized(((1 + expected_size) / 2) * 3); |
59 } |
59 } |
60 |
60 |
|
61 /* Convert a PyInt or PyLong to a long. Returns false if there is an |
|
62 error, in which case an exception will already have been set. */ |
|
63 static inline bool pylong_to_long(PyObject *pylong, long *out) |
|
64 { |
|
65 *out = PyLong_AsLong(pylong); |
|
66 /* Fast path to avoid hitting PyErr_Occurred if the value was obviously |
|
67 * not an error. */ |
|
68 if (*out != -1) { |
|
69 return true; |
|
70 } |
|
71 return PyErr_Occurred() == NULL; |
|
72 } |
|
73 |
61 #endif /* _HG_UTIL_H_ */ |
74 #endif /* _HG_UTIL_H_ */ |