This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
inlining
- To: Guile Mailing List <guile at sourceware dot cygnus dot com>
- Subject: inlining
- From: Dirk Herrmann <dirk at ida dot ing dot tu-bs dot de>
- Date: Fri, 5 May 2000 11:43:23 +0200 (MEST)
Hi!
Those of you that use gcc to compile guile might be interested in the
supplied patch. It adds scm_cons and scm_cons2 as 'inline extern'
functions to pairs.h.
It seems to bring a performance improvement of up to 15%, however, 5% to
10% are more common for some small, selfmade benchmarks.
Just an experiment, but maybe the way to go in the long run? If inline
functions become standard, almost all of guile's macros could be replaced
by inline functions.
Best regards
Dirk
Index: libguile/pairs.h
===================================================================
RCS file: /cvs/guile/guile/guile-core/libguile/pairs.h,v
retrieving revision 1.26
diff -u -r1.26 pairs.h
--- pairs.h 2000/03/29 01:15:56 1.26
+++ pairs.h 2000/05/05 07:52:15
@@ -101,6 +101,49 @@
extern SCM scm_set_cdr_x (SCM pair, SCM value);
extern void scm_init_pairs (void);
+^L
+
+/* {inline functions}
+ */
+
+#ifdef __GNUC__
+
+
+#include "libguile/gc.h"
+
+
+inline extern SCM
+scm_cons (SCM x, SCM y)
+{
+ SCM z;
+ SCM_NEWCELL (z);
+ SCM_SET_CELL_OBJECT_0 (z, x);
+ SCM_SET_CELL_OBJECT_1 (z, y);
+ return z;
+}
+
+
+inline extern SCM
+scm_cons2 (SCM w, SCM x, SCM y)
+{
+ SCM z1;
+ SCM z2;
+
+ SCM_NEWCELL (z1);
+ SCM_SET_CELL_OBJECT_0 (z1, x);
+ SCM_SET_CELL_OBJECT_1 (z1, y);
+
+ SCM_NEWCELL (z2);
+ SCM_SET_CELL_OBJECT_0 (z2, w);
+ SCM_SET_CELL_OBJECT_1 (z2, z1);
+
+ return z2;
+}
+
+
+#endif /* __GNUC__ */
+
+
#endif /* PAIRSH */
/*