[commit: ghc] wip/tdammers/D4568: Improve isReflexiveCo performance (5a83981)

git at git.haskell.org git at git.haskell.org
Mon Apr 16 05:47:16 UTC 2018


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

On branch  : wip/tdammers/D4568
Link       : http://ghc.haskell.org/trac/ghc/changeset/5a83981a7ae1dfbfcda3f460867440ea945dcbeb/ghc

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

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

    Improve isReflexiveCo performance


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

5a83981a7ae1dfbfcda3f460867440ea945dcbeb
 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 c8105d0..b6de283 100644
--- a/compiler/types/Coercion.hs
+++ b/compiler/types/Coercion.hs
@@ -435,7 +435,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