Skip to content
Prev Previous commit
Next Next commit
remove unnecessary critical sections
  • Loading branch information
tom-pytel committed Feb 13, 2025
commit 518d5c5f71c49eea029fa72a363b6653edf36017
5 changes: 0 additions & 5 deletions Objects/bytearrayobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "pycore_bytes_methods.h"
#include "pycore_bytesobject.h"
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
#include "pycore_critical_section.h"
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
#include "pycore_strhex.h" // _Py_strhex_with_sep()
#include "pycore_long.h" // _PyLong_FromUnsignedChar()
Expand Down Expand Up @@ -2530,14 +2529,12 @@ bytearrayiter_next(PyObject *self)
PyByteArrayObject *seq = it->it_seq;
assert(PyByteArray_Check(seq));

Py_BEGIN_CRITICAL_SECTION(seq);
if (index < PyByteArray_GET_SIZE(seq)) {
val = (unsigned char)PyByteArray_AS_STRING(seq)[index];
}
else {
val = -1;
}
Py_END_CRITICAL_SECTION();

if (val == -1) {
FT_ATOMIC_STORE_SSIZE_RELAXED(it->it_index, -1);
Expand Down Expand Up @@ -2581,11 +2578,9 @@ bytearrayiter_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
PyObject *ret = NULL;
Py_ssize_t index = FT_ATOMIC_LOAD_SSIZE_RELAXED(it->it_index);
if (index >= 0) {
Py_BEGIN_CRITICAL_SECTION(it->it_seq);
if (index <= PyByteArray_GET_SIZE(it->it_seq)) {
Comment thread
tom-pytel marked this conversation as resolved.
Outdated
ret = Py_BuildValue("N(O)n", iter, it->it_seq, index);
}
Py_END_CRITICAL_SECTION();
}
if (ret == NULL) {
ret = Py_BuildValue("N(())", iter);
Expand Down