Skip to content

Commit

Permalink
spinoff stringliteral mul into another PR
Browse files Browse the repository at this point in the history
Signed-off-by: martinvuyk <[email protected]>
  • Loading branch information
martinvuyk committed Nov 6, 2024
1 parent a9b3b59 commit 5bb2028
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions stdlib/src/utils/string_slice.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -607,26 +607,6 @@ struct StringSlice[is_mutable: Bool, //, origin: Origin[is_mutable].type,](
"""
return _atof(self)

fn __mul__(self, n: Int) -> String:
"""Concatenates the string `n` times.
Args:
n : The number of times to concatenate the string.
Returns:
The string concatenated `n` times.
"""

len_self = self.byte_length()
count = len_self * n + 1
buf = String._buffer_type(capacity=count)
buf.size = count
b_ptr = buf.unsafe_ptr()
for i in range(n):
memcpy(b_ptr + len_self * i, self.unsafe_ptr(), len_self)
b_ptr[count - 1] = 0
return String(buf^)

# ===------------------------------------------------------------------===#
# Methods
# ===------------------------------------------------------------------===#
Expand Down

0 comments on commit 5bb2028

Please sign in to comment.