git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Optimize mkFn even when the body is not a return statement.
commit82654862fc4865f0889409ad6109b7278e4be076 authorPhil Freeman <paf31@cantab.net> dateTue 15 Jul 2014, 12:56 (12 years ago) parent22fdd3f
1 file changed+5−5
src/Language/PureScript/Optimizer/Inliner.hs+5−5
src/Language/PureScript/Optimizer/Inliner.hs+5−5
@@ -158,19 +158,19 @@ inlineCommonOperators = applyAll $
158158 mkFn 0 = everywhereOnJS convert
159159 where
160160 convert :: JS -> JS
161− convert (JSApp mkFnN [JSFunction Nothing [_] (JSBlock [JSReturn ret])]) | isNFn C.mkFn 0 mkFnN =
162− JSFunction Nothing [] (JSBlock [JSReturn ret])
161+ convert (JSApp mkFnN [JSFunction Nothing [_] (JSBlock js)]) | isNFn C.mkFn 0 mkFnN =
162+ JSFunction Nothing [] (JSBlock js)
163163 convert other = other
164164 mkFn n = everywhereOnJS convert
165165 where
166166 convert :: JS -> JS
167167 convert orig@(JSApp mkFnN [fn]) | isNFn C.mkFn n mkFnN =
168168 case collectArgs n [] fn of
169− Just (args, ret) -> JSFunction Nothing args (JSBlock [JSReturn ret])
169+ Just (args, js) -> JSFunction Nothing args (JSBlock js)
170170 Nothing -> orig
171171 convert other = other
172− collectArgs :: Int -> [String] -> JS -> Maybe ([String], JS)
173− collectArgs 0 acc ret | length acc == n = Just (reverse acc, ret)
172+ collectArgs :: Int -> [String] -> JS -> Maybe ([String], [JS])
173+ collectArgs 1 acc (JSFunction Nothing [oneArg] (JSBlock js)) | length acc == n - 1 = Just (reverse (oneArg : acc), js)
174174 collectArgs m acc (JSFunction Nothing [oneArg] (JSBlock [JSReturn ret])) = collectArgs (m - 1) (oneArg : acc) ret
175175 collectArgs _ _ _ = Nothing
176176