Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit 26ebd25

Browse files
committed
cleanup
1 parent 529f94b commit 26ebd25

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

pyop3/lang.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def _buffer_exchanges(buffer, intent, *, touches_ghost_points):
346346
# reductions
347347
assert intent in {INC, MIN_WRITE, MIN_RW, MAX_WRITE, MAX_RW}
348348
# We don't need to update roots if performing the same reduction
349-
# again. For example we can increment into an buffer as many times
349+
# again. For example we can increment into a buffer as many times
350350
# as we want. The reduction only needs to be done when the
351351
# data is read.
352352
if buffer._roots_valid or intent == buffer._pending_reduction:
@@ -360,16 +360,20 @@ def _buffer_exchanges(buffer, intent, *, touches_ghost_points):
360360
assert buffer._pending_reduction is not None
361361
initializers.append(buffer._reduce_leaves_to_roots_begin)
362362
reductions.append(buffer._reduce_leaves_to_roots_end)
363+
363364
# set leaves to appropriate nil value
364365
if intent == INC:
365-
def _zero():
366-
buffer._data[buffer.sf.ileaf] = 0
367-
reductions.append(_zero)
366+
nil = 0
368367
elif intent in {MIN_WRITE, MIN_RW}:
369-
buffer._data[buffer.sf.ileaf] = dtype_limits(buffer.dtype).max
368+
nil = dtype_limits(buffer.dtype).max
370369
else:
371370
assert intent in {MAX_WRITE, MAX_RW}
372-
buffer._data[buffer.sf.ileaf] = dtype_limits(buffer.dtype).min
371+
nil = dtype_limits(buffer.dtype).min
372+
373+
def _init_nil():
374+
buffer._data[buffer.sf.ileaf] = nil
375+
376+
reductions.append(_init_nil)
373377

374378
# We are modifying owned values so the leaves must now be wrong
375379
buffer._leaves_valid = False

0 commit comments

Comments
 (0)