summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2001-09-19 13:14:19 +0000
committerMarc Espie <espie@cvs.openbsd.org>2001-09-19 13:14:19 +0000
commitda231eb3fbafc2ed237757c0af027b53eae6cd27 (patch)
treef5fc7d0dea4bfbae908a892487a7225c80633898
parentb9db33145250dcbd571b4fed4e5ef762283401d5 (diff)
inline some very common putback/chrsave. Worth roughly 10%
-rw-r--r--usr.bin/m4/eval.c12
-rw-r--r--usr.bin/m4/extern.h23
-rw-r--r--usr.bin/m4/main.c16
-rw-r--r--usr.bin/m4/misc.c14
4 files changed, 42 insertions, 23 deletions
diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c
index ade1fa997a0..868621d2d57 100644
--- a/usr.bin/m4/eval.c
+++ b/usr.bin/m4/eval.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eval.c,v 1.35 2001/09/18 14:55:52 espie Exp $ */
+/* $OpenBSD: eval.c,v 1.36 2001/09/19 13:14:18 espie Exp $ */
/* $NetBSD: eval.c,v 1.7 1996/11/10 21:21:29 pk Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)eval.c 8.2 (Berkeley) 4/27/95";
#else
-static char rcsid[] = "$OpenBSD: eval.c,v 1.35 2001/09/18 14:55:52 espie Exp $";
+static char rcsid[] = "$OpenBSD: eval.c,v 1.36 2001/09/19 13:14:18 espie Exp $";
#endif
#endif /* not lint */
@@ -493,7 +493,7 @@ expand_macro(argv, argc)
p--; /* last character of defn */
while (p > t) {
if (*(p - 1) != ARGFLAG)
- putback(*p);
+ PUTBACK(*p);
else {
switch (*p) {
@@ -532,8 +532,8 @@ expand_macro(argv, argc)
pbstr(lquote);
break;
default:
- putback(*p);
- putback('$');
+ PUTBACK(*p);
+ PUTBACK('$');
break;
}
p--;
@@ -541,7 +541,7 @@ expand_macro(argv, argc)
p--;
}
if (p == t) /* do last character */
- putback(*p);
+ PUTBACK(*p);
}
/*
diff --git a/usr.bin/m4/extern.h b/usr.bin/m4/extern.h
index f13056e0b02..60f5afe1267 100644
--- a/usr.bin/m4/extern.h
+++ b/usr.bin/m4/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.25 2001/09/18 14:55:52 espie Exp $ */
+/* $OpenBSD: extern.h,v 1.26 2001/09/19 13:14:18 espie Exp $ */
/* $NetBSD: extern.h,v 1.3 1996/01/13 23:25:24 pk Exp $ */
/*-
@@ -95,6 +95,27 @@ extern int obtain_char __P((struct input_file *));
extern void set_input __P((struct input_file *, FILE *, const char *));
extern void release_input __P((struct input_file *));
+/* speeded-up versions of chrsave/putback */
+#define PUTBACK(c) \
+ do { \
+ if (bp >= endpbb) \
+ enlarge_bufspace(); \
+ *bp++ = (c); \
+ } while(0)
+
+#define CHRSAVE(c) \
+ do { \
+ if (ep >= endest) \
+ enlarge_strspace(); \
+ *ep++ = (c); \
+ } while(0)
+
+/* and corresponding exposure for local symbols */
+extern void enlarge_bufspace __P((void));
+extern void enlarge_strspace __P((void));
+extern char *endpbb;
+extern char *endest;
+
/* trace.c */
extern void mark_traced __P((const char *));
extern int is_traced __P((const char *));
diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c
index 363c9e38484..e6987b8bd50 100644
--- a/usr.bin/m4/main.c
+++ b/usr.bin/m4/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.47 2001/09/18 20:59:32 espie Exp $ */
+/* $OpenBSD: main.c,v 1.48 2001/09/19 13:14:18 espie Exp $ */
/* $NetBSD: main.c,v 1.12 1997/02/08 23:54:49 cgd Exp $ */
/*-
@@ -47,7 +47,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.47 2001/09/18 20:59:32 espie Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.48 2001/09/19 13:14:18 espie Exp $";
#endif
#endif /* not lint */
@@ -394,7 +394,7 @@ macro()
if (sp < 0)
putc(l, active);
else
- chrsave(l);
+ CHRSAVE(l);
}
}
}
@@ -474,10 +474,10 @@ macro()
}
if (t == EOF)
break;
- chrsave(t);
+ CHRSAVE(t);
}
} else
- chrsave(t); /* stack the char */
+ CHRSAVE(t); /* stack the char */
break;
}
}
@@ -495,7 +495,7 @@ outputstr(s)
putc(*s++, active);
else
while (*s)
- chrsave(*s++);
+ CHRSAVE(*s++);
}
/*
@@ -517,7 +517,7 @@ inspect(c, tp)
while ((isalnum(c = gpbc()) || c == '_') && tp < etp)
h = (h << 5) + h + (*tp++ = c);
- putback(c);
+ PUTBACK(c);
*tp = EOS;
/* token is too long, it won't match anything, but it can still
* be output. */
@@ -527,7 +527,7 @@ inspect(c, tp)
if (sp < 0)
putc(c, active);
else
- chrsave(c);
+ CHRSAVE(c);
}
*name = EOS;
return nil;
diff --git a/usr.bin/m4/misc.c b/usr.bin/m4/misc.c
index b2798789948..89847fbb9ee 100644
--- a/usr.bin/m4/misc.c
+++ b/usr.bin/m4/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.23 2001/09/18 15:46:39 espie Exp $ */
+/* $OpenBSD: misc.c,v 1.24 2001/09/19 13:14:18 espie Exp $ */
/* $NetBSD: misc.c,v 1.6 1995/09/28 05:37:41 tls Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: misc.c,v 1.23 2001/09/18 15:46:39 espie Exp $";
+static char rcsid[] = "$OpenBSD: misc.c,v 1.24 2001/09/19 13:14:18 espie Exp $";
#endif
#endif /* not lint */
@@ -61,7 +61,7 @@ static char rcsid[] = "$OpenBSD: misc.c,v 1.23 2001/09/18 15:46:39 espie Exp $";
char *ep; /* first free char in strspace */
static char *strspace; /* string space for evaluation */
-static char *endest; /* end of string space */
+char *endest; /* end of string space */
static size_t strsize = STRSPMAX;
static size_t bufsize = BUFSIZE;
@@ -69,11 +69,9 @@ char *buf; /* push-back buffer */
char *bufbase; /* the base for current ilevel */
char *bbase[MAXINP]; /* the base for each ilevel */
char *bp; /* first available character */
-static char *endpbb; /* end of push-back buffer */
+char *endpbb; /* end of push-back buffer */
-static void enlarge_bufspace __P((void));
-static void enlarge_strspace __P((void));
/*
* find the index of second str in the first str.
*/
@@ -170,7 +168,7 @@ initspaces()
bbase[i] = buf;
}
-static void
+void
enlarge_strspace()
{
char *newstrspace;
@@ -191,7 +189,7 @@ enlarge_strspace()
endest = strspace + strsize;
}
-static void
+void
enlarge_bufspace()
{
char *newbuf;