mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
add more List.withCapacity optimisation
This commit is contained in:
parent
2b95731a5c
commit
ad9aadeb64
1 changed files with 8 additions and 2 deletions
|
@ -1493,7 +1493,10 @@ expect camelToPascal "someCaseString" == "SomeCaseString"
|
||||||
|
|
||||||
camelToKebeb : Str -> Str
|
camelToKebeb : Str -> Str
|
||||||
camelToKebeb = \str ->
|
camelToKebeb = \str ->
|
||||||
camelToKebabHelp { taken: [], rest: Str.graphemes str }
|
rest = Str.graphemes str
|
||||||
|
taken = List.withCapacity (List.len rest)
|
||||||
|
|
||||||
|
camelToKebabHelp { taken, rest }
|
||||||
|> .taken
|
|> .taken
|
||||||
|> Str.joinWith ""
|
|> Str.joinWith ""
|
||||||
|
|
||||||
|
@ -1517,7 +1520,10 @@ expect camelToKebeb "someCaseString" == "some-case-string"
|
||||||
|
|
||||||
camelToSnake : Str -> Str
|
camelToSnake : Str -> Str
|
||||||
camelToSnake = \str ->
|
camelToSnake = \str ->
|
||||||
camelToSnakeHelp { taken: [], rest: Str.graphemes str }
|
rest = Str.graphemes str
|
||||||
|
taken = List.withCapacity (List.len rest)
|
||||||
|
|
||||||
|
camelToSnakeHelp { taken, rest }
|
||||||
|> .taken
|
|> .taken
|
||||||
|> Str.joinWith ""
|
|> Str.joinWith ""
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue