Skip to content

Commit d58443f

Browse files
committed
cleanup
Signed-off-by: Anatoly Myachev <[email protected]>
1 parent ea27855 commit d58443f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

python/src/interpreter.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ template <typename DType> class AtomicRMWOpBase : public AtomicOp {
113113
protected:
114114
void applyAt(void *loc, size_t i) override final {
115115
if (mask[i]) {
116-
DType *atomic_ptr = static_cast<DType *>(loc);
117-
*(static_cast<DType *>(ret) + i) = applyAtMasked(
118-
atomic_ptr, *(static_cast<const DType *>(val) + i), order);
116+
DType *ptr = static_cast<DType *>(loc);
117+
*(static_cast<DType *>(ret) + i) =
118+
applyAtMasked(ptr, *(static_cast<const DType *>(val) + i), order);
119119
}
120120
}
121121

@@ -294,19 +294,19 @@ void atomic_compare_exchange_strong(void *loc, void *expected,
294294
const void *desired, size_t i,
295295
std::memory_order order) {
296296
T desired_val = *(static_cast<const T *>(desired) + i);
297-
T *expected_uint = static_cast<T *>(expected);
297+
T *expected_uint = static_cast<T *>(expected) + i;
298298

299299
if constexpr (is_reinterpret_cast_to_atomic_safe<T>) {
300300
std::atomic<T> *atomic_loc = reinterpret_cast<std::atomic<T> *>(loc);
301-
atomic_loc->compare_exchange_strong(*(expected_uint + i), desired_val,
302-
order, order);
301+
atomic_loc->compare_exchange_strong(*expected_uint, desired_val, order,
302+
order);
303303
} else {
304304
const std::lock_guard<std::mutex> lock(atomic_op_guard);
305305
T *atomic_loc = static_cast<T *>(loc);
306-
if (*atomic_loc == *(expected_uint + i)) {
306+
if (*atomic_loc == *expected_uint) {
307307
*atomic_loc = desired_val;
308308
} else {
309-
*(expected_uint + i) = *atomic_loc;
309+
*expected_uint = *atomic_loc;
310310
}
311311
}
312312
}

0 commit comments

Comments
 (0)