Skip to content

Commit 581a820

Browse files
JosephTLyonslpil
authored andcommitted
Improve performance of string.drop_start
1 parent 3684de5 commit 581a820

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/gleam/string.gleam

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,9 @@ pub fn crop(from string: String, before substring: String) -> String
232232
/// ```
233233
///
234234
pub fn drop_start(from string: String, up_to num_graphemes: Int) -> String {
235-
case num_graphemes > 0 {
236-
False -> string
237-
True ->
238-
case pop_grapheme(string) {
239-
Ok(#(_, string)) -> drop_start(string, num_graphemes - 1)
240-
Error(Nil) -> string
241-
}
235+
case num_graphemes <= 0 {
236+
True -> string
237+
False -> slice(string, num_graphemes, length(string))
242238
}
243239
}
244240

0 commit comments

Comments
 (0)