[commit: ghc] wip/tdammers/T14737-patch: Improve isReflexiveCo performance (87c547d)

git at git.haskell.org git at git.haskell.org
Thu Apr 5 09:37:03 UTC 2018


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

On branch  : wip/tdammers/T14737-patch
Link       : http://ghc.haskell.org/trac/ghc/changeset/87c547dea0620d92f552275eaa39135bdd4e0423/ghc

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

commit 87c547dea0620d92f552275eaa39135bdd4e0423
Author: Tobias Dammers <tdammers at gmail.com>
Date:   Thu Mar 29 10:45:54 2018 +0200

    Improve isReflexiveCo performance


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

87c547dea0620d92f552275eaa39135bdd4e0423
 compiler/types/Coercion.hs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/compiler/types/Coercion.hs b/compiler/types/Coercion.hs
index 7a7918c..c053233 100644
--- a/compiler/types/Coercion.hs
+++ b/compiler/types/Coercion.hs
@@ -376,7 +376,9 @@ isReflCo_maybe _           = Nothing
 -- | Slowly checks if the coercion is reflexive. Don't call this in a loop,
 -- as it walks over the entire coercion.
 isReflexiveCo :: Coercion -> Bool
-isReflexiveCo = isJust . isReflexiveCo_maybe
+isReflexiveCo (Refl {}) = True
+isReflexiveCo co = eqType ty1 ty2
+  where Pair ty1 ty2 = coercionKind co
 
 -- | Extracts the coerced type from a reflexive coercion. This potentially
 -- walks over the entire coercion, so avoid doing this in a loop.



More information about the ghc-commits mailing list