[commit: ghc] master: Use lengthIs and friends in more places (a786b13)

git at git.haskell.org git at git.haskell.org
Fri Jun 2 18:02:20 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/a786b136f48dfcf907dad55bcdbc4fcd247f2794/ghc

>---------------------------------------------------------------

commit a786b136f48dfcf907dad55bcdbc4fcd247f2794
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Fri Jun 2 13:12:11 2017 -0400

    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


>---------------------------------------------------------------

a786b136f48dfcf907dad55bcdbc4fcd247f2794
 compiler/basicTypes/DataCon.hs               |  4 +--
 compiler/basicTypes/Demand.hs                |  8 +++---
 compiler/basicTypes/MkId.hs                  |  2 +-
 compiler/basicTypes/PatSyn.hs                |  4 +--
 compiler/cmm/CmmBuildInfoTables.hs           |  2 +-
 compiler/cmm/CmmContFlowOpt.hs               |  3 ++-
 compiler/codeGen/StgCmmClosure.hs            |  2 +-
 compiler/codeGen/StgCmmExpr.hs               |  2 +-
 compiler/codeGen/StgCmmLayout.hs             |  2 +-
 compiler/codeGen/StgCmmPrim.hs               |  4 +--
 compiler/codeGen/StgCmmTicky.hs              |  5 ++--
 compiler/coreSyn/CoreLint.hs                 | 12 ++++-----
 compiler/coreSyn/CoreUnfold.hs               |  4 +--
 compiler/coreSyn/CoreUtils.hs                |  8 +++---
 compiler/coreSyn/TrieMap.hs                  |  3 ++-
 compiler/deSugar/Check.hs                    | 12 +++------
 compiler/deSugar/Coverage.hs                 |  2 +-
 compiler/deSugar/DsExpr.hs                   |  4 +--
 compiler/deSugar/MatchCon.hs                 |  2 +-
 compiler/ghci/ByteCodeGen.hs                 |  4 +--
 compiler/ghci/DebuggerUtils.hs               |  4 +--
 compiler/hsSyn/Convert.hs                    |  6 ++---
 compiler/main/InteractiveEval.hs             |  3 ++-
 compiler/nativeGen/Dwarf/Types.hs            |  3 ++-
 compiler/prelude/PrelInfo.hs                 |  2 +-
 compiler/rename/RnPat.hs                     |  2 +-
 compiler/simplCore/CallArity.hs              |  7 ++---
 compiler/simplCore/FloatIn.hs                |  2 +-
 compiler/simplCore/OccurAnal.hs              |  4 +--
 compiler/simplStg/RepType.hs                 |  2 +-
 compiler/simplStg/UnariseStg.hs              |  2 +-
 compiler/specialise/SpecConstr.hs            |  2 +-
 compiler/stgSyn/StgLint.hs                   |  4 +--
 compiler/typecheck/FamInst.hs                |  2 +-
 compiler/typecheck/FunDeps.hs                |  4 +--
 compiler/typecheck/TcCanonical.hs            |  2 +-
 compiler/typecheck/TcDeriv.hs                |  6 ++---
 compiler/typecheck/TcDerivInfer.hs           |  8 +++---
 compiler/typecheck/TcErrors.hs               |  6 ++---
 compiler/typecheck/TcFlatten.hs              |  2 +-
 compiler/typecheck/TcGenDeriv.hs             |  4 +--
 compiler/typecheck/TcGenGenerics.hs          |  6 ++---
 compiler/typecheck/TcPat.hs                  |  2 +-
 compiler/typecheck/TcSplice.hs               |  4 +--
 compiler/typecheck/TcTyClsDecls.hs           |  4 +--
 compiler/typecheck/TcUnify.hs                |  2 +-
 compiler/typecheck/TcValidity.hs             | 12 ++++-----
 compiler/types/Class.hs                      |  2 +-
 compiler/types/Coercion.hs                   |  6 ++---
 compiler/types/OptCoercion.hs                |  6 ++---
 compiler/types/TyCoRep.hs                    | 20 +++++++--------
 compiler/types/TyCon.hs                      | 10 ++++----
 compiler/types/Type.hs                       | 12 ++++-----
 compiler/utils/ListSetOps.hs                 |  2 +-
 compiler/utils/Util.hs                       | 38 ++++++++++++++++++++++++++--
 compiler/vectorise/Vectorise/Type/Env.hs     |  2 +-
 compiler/vectorise/Vectorise/Utils/PADict.hs |  3 ++-
 ghc/GHCi/UI/Monad.hs                         |  5 ++--
 58 files changed, 170 insertions(+), 132 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc a786b136f48dfcf907dad55bcdbc4fcd247f2794


More information about the ghc-commits mailing list