Skip to content

Commit

Permalink
revert get_immutable() -> read()
Browse files Browse the repository at this point in the history
Signed-off-by: martinvuyk <[email protected]>
  • Loading branch information
martinvuyk committed Nov 5, 2024
1 parent c357887 commit 8f51bca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions stdlib/src/builtin/sort.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ fn _quicksort[

# Work with an immutable span so we don't run into exclusivity problems with
# the List[Span].
var imm_span = span.read()
var imm_span = span.get_immutable()
alias ImmSpan = __type_of(imm_span)

var stack = List[ImmSpan](capacity=_estimate_initial_height(size))
Expand Down Expand Up @@ -341,7 +341,9 @@ fn _stable_sort_impl[
while j + merge_size < size:
var span1 = span[j : j + merge_size]
var span2 = span[j + merge_size : min(size, j + 2 * merge_size)]
_merge[cmp_fn](span1.read(), span2.read(), temp_buff)
_merge[cmp_fn](
span1.get_immutable(), span2.get_immutable(), temp_buff
)
for i in range(merge_size + len(span2)):
span[j + i] = temp_buff[i]
j += 2 * merge_size
Expand Down
2 changes: 1 addition & 1 deletion stdlib/src/utils/span.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ struct Span[
for element in self:
element[] = value

fn read(self) -> Span[T, _lit_mut_cast[origin, False].result]:
fn get_immutable(self) -> Span[T, _lit_mut_cast[origin, False].result]:
"""
Return an immutable version of this span.
Expand Down

0 comments on commit 8f51bca

Please sign in to comment.