From a786b136f48dfcf907dad55bcdbc4fcd247f2794 Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Fri, 2 Jun 2017 13:12:11 -0400 Subject: Use lengthIs and friends in more places While investigating #12545, I discovered several places in the code that performed length-checks like so: ``` length ts == 4 ``` This is not ideal, since the length of `ts` could be much longer than 4, and we'd be doing way more work than necessary! There are already a slew of helper functions in `Util` such as `lengthIs` that are designed to do this efficiently, so I found every place where they ought to be used and did just that. I also defined a couple more utility functions for list length that were common patterns (e.g., `ltLength`). Test Plan: ./validate Reviewers: austin, hvr, goldfire, bgamari, simonmar Reviewed By: bgamari, simonmar Subscribers: goldfire, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3622 --- compiler/specialise/SpecConstr.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compiler/specialise') diff --git a/compiler/specialise/SpecConstr.hs b/compiler/specialise/SpecConstr.hs index 39ec7e6946..e5af0b8a3c 100644 --- a/compiler/specialise/SpecConstr.hs +++ b/compiler/specialise/SpecConstr.hs @@ -1984,7 +1984,7 @@ callToPats :: ScEnv -> [ArgOcc] -> Call -> UniqSM (Maybe CallPat) -- over the following term variables -- The [CoreExpr] are the argument patterns for the rule callToPats env bndr_occs (Call _ args con_env) - | length args < length bndr_occs -- Check saturated + | args `ltLength` bndr_occs -- Check saturated = return Nothing | otherwise = do { let in_scope = substInScope (sc_subst env) -- cgit v1.2.1