Skip to content

Commit

Permalink
Optimize putLast
Browse files Browse the repository at this point in the history
  • Loading branch information
cubandle committed Jan 15, 2023
1 parent 0f6c009 commit 800e958
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ fun DateTimeUnit.toMillis(): Long {
* Puts the specified value to the last key in this map.
*/
fun <K, V> LinkedHashMap<K, V>.putLast(value: V) {
val lastKey = keys.map { it }.last()
put(lastKey, value)
put(keys.last(), value)
}

0 comments on commit 800e958

Please sign in to comment.