mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
inline some very common putback/chrsave. Worth roughly 10%
This commit is contained in:
parent
20e08abf14
commit
dd84b4a63e
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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 *));
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user