Skip to content

Commit

Permalink
Remove StringLiteral StringRef dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: martinvuyk <[email protected]>
  • Loading branch information
martinvuyk committed Dec 11, 2024
1 parent 7ea103c commit 893ec6f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions stdlib/src/builtin/string_literal.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ from sys.ffi import c_char

from memory import UnsafePointer, memcpy, Span

from utils import StaticString, StringRef, StringSlice, Writable, Writer
from utils import StaticString, StringSlice, Writable, Writer
from utils._visualizers import lldb_formatter_wrapping_type
from utils.format import _CurlyEntryFormattable, _FormatCurlyEntry
from utils.string_slice import _StringSliceIter, _to_string_list
Expand Down Expand Up @@ -241,7 +241,7 @@ struct StringLiteral(
Returns:
True if they are not equal.
"""
return StringRef(self) != StringRef(rhs)
return self.as_string_slice() != rhs.as_string_slice()

@always_inline("nodebug")
fn __eq__(self, rhs: StringSlice) -> Bool:
Expand Down Expand Up @@ -277,7 +277,7 @@ struct StringLiteral(
Returns:
True if this StringLiteral is strictly less than the RHS StringLiteral and False otherwise.
"""
return StringRef(self) < StringRef(rhs)
return self.as_string_slice() < rhs.as_string_slice()

@always_inline("nodebug")
fn __le__(self, rhs: StringLiteral) -> Bool:
Expand Down Expand Up @@ -324,7 +324,7 @@ struct StringLiteral(
Returns:
True if the string contains the substring.
"""
return substr in StringRef(self)
return substr in self.as_string_slice()

# ===-------------------------------------------------------------------===#
# Trait implementations
Expand Down Expand Up @@ -606,7 +606,7 @@ struct StringLiteral(
Returns:
The offset of `substr` relative to the beginning of the string.
"""
return StringRef(self).find(substr, start=start)
return self.as_string_slice().find(substr, start=start)

fn rfind(self, substr: StringLiteral, start: Int = 0) -> Int:
"""Finds the offset of the last occurrence of `substr` starting at
Expand All @@ -619,7 +619,7 @@ struct StringLiteral(
Returns:
The offset of `substr` relative to the beginning of the string.
"""
return StringRef(self).rfind(substr, start=start)
return self.as_string_slice().rfind(substr, start=start)

fn replace(self, old: StringLiteral, new: StringLiteral) -> StringLiteral:
"""Return a copy of the string with all occurrences of substring `old`
Expand Down

0 comments on commit 893ec6f

Please sign in to comment.