Skip to content

Commit 9cf07fa

Browse files
post code review edits
1 parent 056e2c5 commit 9cf07fa

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

Objects/codeobject.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ PyCode_ClearWatcher(int watcher_id)
113113

114114
#define _PyCodeObject_CAST(op) (assert(PyCode_Check(op)), (PyCodeObject *)(op))
115115

116-
static inline int
116+
static int
117117
should_intern_string(PyObject *o)
118118
{
119119
#ifdef Py_GIL_DISABLED
@@ -196,14 +196,15 @@ intern_strings(PyObject *tuple)
196196
return 0;
197197
}
198198

199-
#define _constants_tuple_modified(modified) if (modified) *modified = 1
200199

201200
/* Intern constants. In the default build, this interns selected string
202-
constants. In the free-threaded build, this also interns non-string
203-
constants. */
201+
constants. In the free-threaded build, this also interns non-string
202+
constants. */
204203
static int
205204
intern_constants(PyObject *tuple, int *modified)
206205
{
206+
#define set_modified(modified) if (modified) *modified = 1
207+
207208
PyInterpreterState *interp = _PyInterpreterState_GET();
208209
for (Py_ssize_t i = PyTuple_GET_SIZE(tuple); --i >= 0; ) {
209210
PyObject *v = PyTuple_GET_ITEM(tuple, i);
@@ -215,21 +216,23 @@ intern_constants(PyObject *tuple, int *modified)
215216
PyObject *interned = _Py_hashtable_get(INTERNED_STRINGS, v);
216217
if (interned == NULL) {
217218
interned = PyDict_GetItemWithError(get_interned_dict(interp), v);
218-
if (PyErr_Occurred()) return -1;
219+
if (PyErr_Occurred()) {
220+
return -1;
221+
}
219222
}
220223
if (interned != NULL && interned != v) {
221224
Py_INCREF(interned);
222225
PyTuple_SET_ITEM(tuple, i, interned);
223226
Py_DECREF(v);
224-
_constants_tuple_modified(modified);
227+
set_modified(modified);
225228
} else
226229
#endif
227230
if (should_intern_string(v)) {
228231
PyObject *w = v;
229232
_PyUnicode_InternMortal(interp, &v);
230233
if (w != v) {
231234
PyTuple_SET_ITEM(tuple, i, v);
232-
_constants_tuple_modified(modified);
235+
set_modified(modified);
233236
}
234237
}
235238
}
@@ -258,7 +261,7 @@ intern_constants(PyObject *tuple, int *modified)
258261

259262
PyTuple_SET_ITEM(tuple, i, v);
260263
Py_DECREF(w);
261-
_constants_tuple_modified(modified);
264+
set_modified(modified);
262265
}
263266
Py_DECREF(tmp);
264267
}
@@ -287,7 +290,7 @@ intern_constants(PyObject *tuple, int *modified)
287290
}
288291
PyTuple_SET_ITEM(tuple, i, v);
289292
Py_DECREF(slice);
290-
_constants_tuple_modified(modified);
293+
set_modified(modified);
291294
}
292295
Py_DECREF(tmp);
293296
}
@@ -311,6 +314,8 @@ intern_constants(PyObject *tuple, int *modified)
311314
#endif
312315
}
313316
return 0;
317+
318+
#undef set_modified
314319
}
315320

316321
/* Return a shallow copy of a tuple that is

0 commit comments

Comments
 (0)