summaryrefslogtreecommitdiff
path: root/compiler/vectorise/Vectorise
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2017-06-02 13:12:11 -0400
committerBen Gamari <ben@smart-cactus.org>2017-06-02 13:12:13 -0400
commita786b136f48dfcf907dad55bcdbc4fcd247f2794 (patch)
tree9c6abee43aa398fdd8168b1cb7bd2d3fb5e6bacf /compiler/vectorise/Vectorise
parent811a2986475d88f73bb22b4600970039e1b582d6 (diff)
downloadhaskell-a786b136f48dfcf907dad55bcdbc4fcd247f2794.tar.gz
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
Diffstat (limited to 'compiler/vectorise/Vectorise')
-rw-r--r--compiler/vectorise/Vectorise/Type/Env.hs2
-rw-r--r--compiler/vectorise/Vectorise/Utils/PADict.hs3
2 files changed, 3 insertions, 2 deletions
diff --git a/compiler/vectorise/Vectorise/Type/Env.hs b/compiler/vectorise/Vectorise/Type/Env.hs
index 612c051a2c..9526feddaf 100644
--- a/compiler/vectorise/Vectorise/Type/Env.hs
+++ b/compiler/vectorise/Vectorise/Type/Env.hs
@@ -365,7 +365,7 @@ vectTypeEnv tycons vectTypeDecls vectClassDecls
defDataCons
| isAbstract = return ()
| otherwise
- = do { MASSERT(length (tyConDataCons origTyCon) == length (tyConDataCons vectTyCon))
+ = do { MASSERT(tyConDataCons origTyCon `equalLength` tyConDataCons vectTyCon)
; zipWithM_ defDataCon (tyConDataCons origTyCon) (tyConDataCons vectTyCon)
}
diff --git a/compiler/vectorise/Vectorise/Utils/PADict.hs b/compiler/vectorise/Vectorise/Utils/PADict.hs
index 9cd740cf53..4d32f5df74 100644
--- a/compiler/vectorise/Vectorise/Utils/PADict.hs
+++ b/compiler/vectorise/Vectorise/Utils/PADict.hs
@@ -22,6 +22,7 @@ import Var
import Outputable
import DynFlags
import FastString
+import Util
import Control.Monad
@@ -199,7 +200,7 @@ prDFunApply dfun tys
= return $ Var dfun `mkTyApps` tys
| Just tycons <- ctxs
- , length tycons == length tys
+ , tycons `equalLength` tys
= do
pa <- builtin paTyCon
pr <- builtin prTyCon