mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-21 10:41:39 +03:00
Avoid Dict to List conversions to improve performance.
This commit is contained in:
parent
56dec4752c
commit
78746c1195
@ -481,16 +481,19 @@ It would not work correctly if it chose between two responses that were reduced
|
|||||||
-}
|
-}
|
||||||
combineReducedDicts : Dict String WhatToDo -> Dict String WhatToDo -> Dict String WhatToDo
|
combineReducedDicts : Dict String WhatToDo -> Dict String WhatToDo -> Dict String WhatToDo
|
||||||
combineReducedDicts dict1 dict2 =
|
combineReducedDicts dict1 dict2 =
|
||||||
(Dict.toList dict1 ++ Dict.toList dict2)
|
if Dict.size dict1 > Dict.size dict2 then
|
||||||
|> fromListDedupe Pages.StaticHttpRequest.merge
|
uniqueInsertAll dict2 dict1
|
||||||
|
|
||||||
|
else
|
||||||
|
uniqueInsertAll dict1 dict2
|
||||||
|
|
||||||
|
|
||||||
fromListDedupe : (comparable -> a -> a -> a) -> List ( comparable, a ) -> Dict comparable a
|
uniqueInsertAll : Dict String WhatToDo -> Dict String WhatToDo -> Dict String WhatToDo
|
||||||
fromListDedupe combineFn xs =
|
uniqueInsertAll dictToDedupeMerge startingDict =
|
||||||
List.foldl
|
Dict.foldl
|
||||||
(\( key, value ) acc -> Dict.Extra.insertDedupe (combineFn key) key value acc)
|
(\key value acc -> Dict.Extra.insertDedupe (Pages.StaticHttpRequest.merge key) key value acc)
|
||||||
Dict.empty
|
startingDict
|
||||||
xs
|
dictToDedupeMerge
|
||||||
|
|
||||||
|
|
||||||
lookup : KeepOrDiscard -> ApplicationType -> DataSource value -> RequestsAndPending -> Result Pages.StaticHttpRequest.Error ( Dict String WhatToDo, value )
|
lookup : KeepOrDiscard -> ApplicationType -> DataSource value -> RequestsAndPending -> Result Pages.StaticHttpRequest.Error ( Dict String WhatToDo, value )
|
||||||
|
Loading…
Reference in New Issue
Block a user