[m-rev.] for review: type_to_univ speedup

Zoltan Somogyi zs at cs.mu.OZ.AU
Tue Dec 18 14:28:37 AEDT 2001


For review by anyone.

Estimated hours taken: 0.1
Branches: main

library/std_util.m:
	Replace dynamic checks in type_to_univ with mode-specific clauses.

Zoltan.

Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.248
diff -u -b -r1.248 std_util.m
--- library/std_util.m	2001/11/08 06:36:54	1.248
+++ library/std_util.m	2001/12/17 18:00:11
@@ -1264,16 +1264,15 @@
 univ_value(univ_cons(X)) = X.
 
 :- pragma promise_pure(type_to_univ/2).
-type_to_univ(T, Univ) :-
-	(
-		impure private_builtin__var(T),
-		Univ = univ_cons(T0),
-		private_builtin__typed_unify(T0, T)
-	;
-		impure private_builtin__var(Univ),
+type_to_univ(T::di, Univ::uo) :-
+	Univ0 = 'new univ_cons'(T),
+	unsafe_promise_unique(Univ0, Univ).
+type_to_univ(T::in, Univ::out) :-
 		Univ0 = 'new univ_cons'(T),
-		unsafe_promise_unique(Univ0, Univ)
-	).
+	unsafe_promise_unique(Univ0, Univ).
+type_to_univ(T::out, Univ::in) :-
+	Univ = univ_cons(T0),
+	private_builtin__typed_unify(T0, T).
 
 univ_type(Univ) = type_of(univ_value(Univ)).
 
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list