[m-dev.] diff: map__is_empty

Zoltan Somogyi zs at cs.mu.OZ.AU
Tue Mar 28 13:04:58 AEST 2000


Estimated hours taken: 0.5

Make {multi_,}map__is_empty more efficient.

library/tree234.m:
	Add a tree234__is_empty predicate.

library/map.m:
library/multi_map.m:
	Call tree234__is_empty instead of tree234__init, since this does not
	require a complicated unification.


Zoltan.

cvs diff: Diffing library
Index: library/map.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/map.m,v
retrieving revision 1.70
diff -u -b -r1.70 map.m
--- library/map.m	1999/07/07 15:19:40	1.70
+++ library/map.m	2000/03/27 07:42:15
@@ -1,5 +1,5 @@
 %---------------------------------------------------------------------------%
-% Copyright (C) 1993-1999 The University of Melbourne.
+% Copyright (C) 1993-2000 The University of Melbourne.
 % This file may only be copied under the terms of the GNU Library General
 % Public License - see the file COPYING.LIB in the Mercury distribution.
 %-----------------------------------------------------------------------------%
@@ -259,7 +259,7 @@
 	tree234__init(M).
 
 map__is_empty(M) :-
-	tree234__init(M).
+	tree234__is_empty(M).
 
 map__contains(Map, K) :-
 	map__search(Map, K, _).
Index: library/multi_map.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/multi_map.m,v
retrieving revision 1.7
diff -u -b -r1.7 multi_map.m
--- library/multi_map.m	1998/01/23 12:33:24	1.7
+++ library/multi_map.m	2000/03/27 07:42:01
@@ -1,5 +1,5 @@
 %---------------------------------------------------------------------------%
-% Copyright (C) 1995, 1997 The University of Melbourne.
+% Copyright (C) 1995, 1997, 2000 The University of Melbourne.
 % This file may only be copied under the terms of the GNU Library General
 % Public License - see the file COPYING.LIB in the Mercury distribution.
 %-----------------------------------------------------------------------------%
@@ -197,7 +197,7 @@
 	map__init(M).
 
 multi_map__is_empty(M) :-
-	map__init(M).
+	map__is_empty(M).
 
 multi_map__contains(MultiMap, Key) :-
 	map__search(MultiMap, Key, _).
Index: library/tree234.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/tree234.m,v
retrieving revision 1.27
diff -u -b -r1.27 tree234.m
--- library/tree234.m	1999/10/30 04:16:12	1.27
+++ library/tree234.m	2000/03/27 07:42:08
@@ -1,5 +1,5 @@
 %---------------------------------------------------------------------------%
-% Copyright (C) 1994-1997, 1999 The University of Melbourne.
+% Copyright (C) 1994-1997, 1999-2000 The University of Melbourne.
 % This file may only be copied under the terms of the GNU Library General
 % Public License - see the file COPYING.LIB in the Mercury distribution.
 %---------------------------------------------------------------------------%
@@ -23,6 +23,9 @@
 :- pred tree234__init(tree234(K, V)).
 :- mode tree234__init(uo) is det.
 
+:- pred tree234__is_empty(tree234(K, V)).
+:- mode tree234__is_empty(in) is semidet.
+
 :- pred tree234__member(tree234(K, V), K, V).
 :- mode tree234__member(in, out, out) is nondet.
 
@@ -148,6 +151,9 @@
 %------------------------------------------------------------------------------%
 
 tree234__init(empty).
+
+tree234__is_empty(Tree) :-
+	Tree = empty.
 
 %------------------------------------------------------------------------------%
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list