Skip to content

Commit

Permalink
[mojo-stdlib] Minor cleanups for Tuple, NFC.
Browse files Browse the repository at this point in the history
These are just minor improvements to `Tuple` from a walkthrough
with @VerdagonModular.

MODULAR_ORIG_COMMIT_REV_ID: 352c9d3bc6494f4696a405bf3d992cfced5dce89
  • Loading branch information
lattner authored and modularbot committed Dec 3, 2024
1 parent 30fa4c3 commit a4f67f1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions stdlib/src/builtin/tuple.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ struct Tuple[*element_types: CollectionElement](Sized, CollectionElement):
UnsafePointer.address_of(self[i])
)

# Mark the elements as destroyed.
storage._is_owned = False
# Do not destroy the elements when 'storage' goes away.
__mlir_op.`lit.ownership.mark_destroyed`(
__get_mvalue_as_litref(storage)
)

fn __del__(owned self):
"""Destructor that destroys all of the elements."""
Expand Down Expand Up @@ -126,6 +128,7 @@ struct Tuple[*element_types: CollectionElement](Sized, CollectionElement):
UnsafePointer.address_of(existing[i]).move_pointee_into(
UnsafePointer.address_of(self[i])
)
# Note: The destructor on `existing` is auto-disabled in a moveinit.

@always_inline
@staticmethod
Expand Down

0 comments on commit a4f67f1

Please sign in to comment.