Skip to content

Commit

Permalink
Suggest posLine . lengthAsPosition instead of lengthInLines
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Apr 25, 2022
1 parent 8939b8a commit 1f721c1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Data/Text/Rope.hs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ lastChar = \case
-- >>> lengthInLines "foo\nbar"
-- 2
--
-- If you do not care about ignoring the last newline character,
-- you can use 'posLine' . 'lengthAsPosition' instead, which works in O(1).
--
lengthInLines :: Rope -> Word
lengthInLines rp = case lastChar rp of
Nothing -> 0
Expand Down
3 changes: 3 additions & 0 deletions src/Data/Text/Utf16/Rope.hs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ lastChar = \case
-- >>> lengthInLines "foo\nbar"
-- 2
--
-- If you do not care about ignoring the last newline character,
-- you can use 'posLine' . 'lengthAsPosition' instead, which works in O(1).
--
lengthInLines :: Rope -> Word
lengthInLines rp = case lastChar rp of
Nothing -> 0
Expand Down
3 changes: 3 additions & 0 deletions src/Data/Text/Utf16/Rope/Mixed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ lastChar = \case
-- >>> lengthInLines "foo\nbar"
-- 2
--
-- If you do not care about ignoring the last newline character,
-- you can use 'Char.posLine' . 'charLengthAsPosition' instead, which works in O(1).
--
lengthInLines :: Rope -> Word
lengthInLines rp = case lastChar rp of
Nothing -> 0
Expand Down

0 comments on commit 1f721c1

Please sign in to comment.