From 4e0c4d3fe63a225f021dfb43d42a0ad00dd5a7de Mon Sep 17 00:00:00 2001 From: Dillon Kearns Date: Thu, 29 Jul 2021 10:06:46 -0700 Subject: [PATCH] Make function call tail-call optimized. --- src/Pages/StaticHttpRequest.elm | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Pages/StaticHttpRequest.elm b/src/Pages/StaticHttpRequest.elm index e8460cba..a7e36e97 100644 --- a/src/Pages/StaticHttpRequest.elm +++ b/src/Pages/StaticHttpRequest.elm @@ -250,11 +250,11 @@ resolve appType request rawResponses = resolveUrls : ApplicationType -> RawRequest value -> RequestsAndPending -> List (Secrets.Value Pages.StaticHttp.Request.Request) resolveUrls appType request rawResponses = - resolveUrlsHelp appType request rawResponses [] + resolveUrlsHelp appType rawResponses [] request -resolveUrlsHelp : ApplicationType -> RawRequest value -> RequestsAndPending -> List (Secrets.Value Pages.StaticHttp.Request.Request) -> List (Secrets.Value Pages.StaticHttp.Request.Request) -resolveUrlsHelp appType request rawResponses soFar = +resolveUrlsHelp : ApplicationType -> RequestsAndPending -> List (Secrets.Value Pages.StaticHttp.Request.Request) -> RawRequest value -> List (Secrets.Value Pages.StaticHttp.Request.Request) +resolveUrlsHelp appType rawResponses soFar request = case request of RequestError error -> case error of @@ -266,13 +266,10 @@ resolveUrlsHelp appType request rawResponses soFar = soFar Request _ ( urlList, lookupFn ) -> - lookupFn KeepOrDiscard.Keep appType rawResponses - |> (\nextRequest -> - resolveUrlsHelp appType - nextRequest - rawResponses - (soFar ++ urlList) - ) + resolveUrlsHelp appType + rawResponses + (soFar ++ urlList) + (lookupFn KeepOrDiscard.Keep appType rawResponses) Done _ _ -> soFar