This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
[PATCH] inline scm_getc()
- To: guile at sourceware dot cygnus dot com
- Subject: [PATCH] inline scm_getc()
- From: Chris Cramer <crayc at kiwi dot pyro dot net>
- Date: Sun, 30 Apr 2000 21:56:58 -0500
This patch inlines scm_getc(). Cuts startup time by .1 seconds --
startup time is now .5 seconds on my system.
Actually, I should've made it extern and not removed it from ports.c...
--
C. Ray C. aka Christopher Cramer
crayc@pyro.net
http://www.pyro.net/~crayc/
diff -ru old/guile-1.3.4/libguile/ports.c guile-1.3.4/libguile/ports.c
--- old/guile-1.3.4/libguile/ports.c Mon Sep 20 16:34:57 1999
+++ guile-1.3.4/libguile/ports.c Sun Apr 30 19:06:21 2000
@@ -697,45 +697,6 @@
return scm_ptobs[SCM_PTOBNUM (port)].fill_input (port);
}
-int
-scm_getc (SCM port)
-{
- int c;
- scm_port *pt = SCM_PTAB_ENTRY (port);
-
- if (pt->rw_active == SCM_PORT_WRITE)
- {
- /* may be marginally faster than calling scm_flush. */
- scm_ptobs[SCM_PTOBNUM (port)].flush (port);
- }
-
- if (pt->rw_random)
- pt->rw_active = SCM_PORT_READ;
-
- if (pt->read_pos >= pt->read_end)
- {
- if (scm_fill_input (port) == EOF)
- return EOF;
- }
-
- c = *(pt->read_pos++);
-
- if (c == '\n')
- {
- SCM_INCLINE (port);
- }
- else if (c == '\t')
- {
- SCM_TABCOL (port);
- }
- else
- {
- SCM_INCCOL (port);
- }
-
- return c;
-}
-
void
scm_putc (char c, SCM port)
{
diff -ru old/guile-1.3.4/libguile/ports.h guile-1.3.4/libguile/ports.h
--- old/guile-1.3.4/libguile/ports.h Thu Aug 19 19:44:14 1999
+++ guile-1.3.4/libguile/ports.h Sun Apr 30 19:42:33 2000
@@ -50,6 +50,7 @@
/* Not sure if this is a good idea. We need it for off_t. */
#include <sys/types.h>
+#include <stdio.h>
@@ -269,7 +270,6 @@
extern void scm_flush SCM_P ((SCM port));
extern void scm_end_input (SCM port);
extern int scm_fill_input (SCM port);
-extern int scm_getc SCM_P ((SCM port));
extern void scm_ungetc SCM_P ((int c, SCM port));
extern void scm_ungets SCM_P ((char *s, int n, SCM port));
extern SCM scm_peek_char SCM_P ((SCM port));
@@ -295,5 +295,39 @@
extern SCM scm_pt_size SCM_P ((void));
extern SCM scm_pt_member SCM_P ((SCM member));
#endif /* GUILE_DEBUG */
+
+static inline int
+scm_getc (SCM port)
+{
+ int c;
+ scm_port *pt = SCM_PTAB_ENTRY (port);
+
+ if (pt->rw_active == SCM_PORT_WRITE) scm_flush(port);
+
+ if (pt->rw_random) pt->rw_active = SCM_PORT_READ;
+
+ if (pt->read_pos >= pt->read_end)
+ {
+ if (scm_fill_input (port) == EOF)
+ return EOF;
+ }
+
+ c = *(pt->read_pos++);
+
+ if (c == '\n')
+ {
+ SCM_INCLINE (port);
+ }
+ else if (c == '\t')
+ {
+ SCM_TABCOL (port);
+ }
+ else
+ {
+ SCM_INCCOL (port);
+ }
+
+ return c;
+}
#endif /* PORTSH */