@@ -27,7 +27,7 @@ pub fn is_empty(str: String) -> Bool {
2727/// Gets the number of grapheme clusters in a given `String`.
2828///
2929/// This function has to iterate across the whole string to count the number of
30- /// graphemes, so it runs in linear time.
30+ /// graphemes, so it runs in linear time. Avoid using this in a loop.
3131///
3232/// ## Examples
3333///
@@ -53,7 +53,7 @@ pub fn length(string: String) -> Int
5353/// Reverses a `String`.
5454///
5555/// This function has to iterate across the whole `String` so it runs in linear
56- /// time.
56+ /// time. Avoid using this in a loop.
5757///
5858/// ## Examples
5959///
@@ -160,6 +160,10 @@ fn less_than(a: String, b: String) -> Bool
160160/// Takes a substring given a start grapheme index and a length. Negative indexes
161161/// are taken starting from the *end* of the list.
162162///
163+ /// This function runs in linear time with the size of the index and the
164+ /// length. Negative indexes are linear with the size of the input string in
165+ /// addition to the other costs.
166+ ///
163167/// ## Examples
164168///
165169/// ```gleam
@@ -252,7 +256,7 @@ pub fn drop_start(from string: String, up_to num_graphemes: Int) -> String {
252256/// Drops *n* graphemes from the end of a `String`.
253257///
254258/// This function traverses the full string, so it runs in linear time with the
255- /// size of the string.
259+ /// size of the string. Avoid using this in a loop.
256260///
257261/// ## Examples
258262///
@@ -805,6 +809,9 @@ pub fn first(string: String) -> Result(String, Nil) {
805809/// `Result(String, Nil)`. If the `String` is empty, it returns `Error(Nil)`.
806810/// Otherwise, it returns `Ok(String)`.
807811///
812+ /// This function traverses the full string, so it runs in linear time with the
813+ /// length of the string. Avoid using this in a loop.
814+ ///
808815/// ## Examples
809816///
810817/// ```gleam
0 commit comments