This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Small splay-tree addition
- To: egcs-patches at egcs dot cygnus dot com
- Subject: Small splay-tree addition
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Fri, 2 Apr 1999 15:20:50 -0800
- Reply-to: mark at codesourcery dot com
This patch provides a new splay-tree comparison function, for use in
the C++ front-end. I've checked this in; if anyone objects shout.
Of course, pointer comparison doesn't has "unspecified" semantics, but
I believe that all systems of interest guarantee that `<' is a total
ordering on pointers; such facts as a < b => b > a and a < b, b < c =>
a < c, and so forth. If not, please let me know, and I will remove
this function, and provide a slower comparison function for the C++
front-end to use.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
1999-04-02 Mark Mitchell <mark@codesourcery.com>
* splay-tree.h (splay_tree_compare_pointers): Declare.
1999-04-02 Mark Mitchell <mark@codesourcery.com>
* splay-tree.h (splay_tree_compare_pointers): Define.
Index: include/splay-tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/include/splay-tree.h,v
retrieving revision 1.7
diff -c -p -r1.7 splay-tree.h
*** splay-tree.h 1999/03/30 20:52:22 1.7
--- splay-tree.h 1999/04/02 23:09:55
*************** extern int splay_tree_foreach
*** 106,111 ****
--- 106,113 ----
void*));
extern int splay_tree_compare_ints PARAMS((splay_tree_key,
splay_tree_key));
+ extern int splay_tree_compare_pointers PARAMS((splay_tree_key,
+ splay_tree_key));
#ifdef __cplusplus
}
Index: libiberty/splay-tree.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/libiberty/splay-tree.c,v
retrieving revision 1.8
diff -c -p -r1.8 splay-tree.c
*** splay-tree.c 1999/03/30 20:52:24 1.8
--- splay-tree.c 1999/04/02 23:09:57
*************** splay_tree_compare_ints (k1, k2)
*** 351,353 ****
--- 351,368 ----
else
return 0;
}
+
+ /* Splay-tree comparison function, treating the keys as pointers. */
+
+ int
+ splay_tree_compare_pointers (k1, k2)
+ splay_tree_key k1;
+ splay_tree_key k2;
+ {
+ if ((char*) k1 < (char*) k2)
+ return -1;
+ else if ((char*) k1 > (char*) k2)
+ return 1;
+ else
+ return 0;
+ }