summaryrefslogtreecommitdiff
path: root/x2p
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2012-08-16 10:50:14 -0600
committerKarl Williamson <public@khwilliamson.com>2012-08-18 11:26:37 -0600
commiteb578fdb5569b91c28466a4d1939e381ff6ceaf4 (patch)
treecb76dfdd15ead716ff76b6a46eb1c49f10b302f2 /x2p
parent29205e9cdf0a179ed7a2e9401a3b19c8ede062db (diff)
downloadperl-eb578fdb5569b91c28466a4d1939e381ff6ceaf4.tar.gz
Omnibus removal of register declarations
This removes most register declarations in C code (and accompanying documentation) in the Perl core. Retained are those in the ext directory, Configure, and those that are associated with assembly language. See: http://stackoverflow.com/questions/314994/whats-a-good-example-of-register-variable-usage-in-c which says, in part: There is no good example of register usage when using modern compilers (read: last 10+ years) because it almost never does any good and can do some bad. When you use register, you are telling the compiler "I know how to optimize my code better than you do" which is almost never the case. One of three things can happen when you use register: The compiler ignores it, this is most likely. In this case the only harm is that you cannot take the address of the variable in the code. The compiler honors your request and as a result the code runs slower. The compiler honors your request and the code runs faster, this is the least likely scenario. Even if one compiler produces better code when you use register, there is no reason to believe another will do the same. If you have some critical code that the compiler is not optimizing well enough your best bet is probably to use assembler for that part anyway but of course do the appropriate profiling to verify the generated code is really a problem first.
Diffstat (limited to 'x2p')
-rw-r--r--x2p/a2p.c4
-rw-r--r--x2p/a2py.c28
-rw-r--r--x2p/hash.c32
-rw-r--r--x2p/str.c18
-rw-r--r--x2p/util.c6
-rw-r--r--x2p/walk.c26
6 files changed, 57 insertions, 57 deletions
diff --git a/x2p/a2p.c b/x2p/a2p.c
index 1a7a77851e..8d6e9cde57 100644
--- a/x2p/a2p.c
+++ b/x2p/a2p.c
@@ -2191,9 +2191,9 @@ EXTERN_C char *getenv(const char *);
int
yyparse(void)
{
- register int yym, yyn, yystate;
+ int yym, yyn, yystate;
#if YYDEBUG
- register const char *yys;
+ const char *yys;
if ((yys = getenv("YYDEBUG")))
{
diff --git a/x2p/a2py.c b/x2p/a2py.c
index f6944b9005..2f41ca86ec 100644
--- a/x2p/a2py.c
+++ b/x2p/a2py.c
@@ -61,7 +61,7 @@ usage()
int
main(register int argc, register const char **argv, register const char **env)
{
- register STR *str;
+ STR *str;
int i;
STR *tmpstr;
/* char *namelist; */
@@ -221,9 +221,9 @@ int idtype;
int
yylex(void)
{
- register char *s = bufptr;
- register char *d;
- register int tmp;
+ char *s = bufptr;
+ char *d;
+ int tmp;
retry:
#if YYDEBUG
@@ -828,7 +828,7 @@ yylex(void)
char *
scanpat(register char *s)
{
- register char *d;
+ char *d;
switch (*s++) {
case '/':
@@ -880,7 +880,7 @@ yyerror(const char *s)
char *
scannum(register char *s)
{
- register char *d;
+ char *d;
switch (*s) {
case '1': case '2': case '3': case '4': case '5':
@@ -1027,9 +1027,9 @@ int depth = 0;
void
dump(int branch)
{
- register int type;
- register int len;
- register int i;
+ int type;
+ int len;
+ int i;
type = ops[branch].ival;
len = type >> 8;
@@ -1067,8 +1067,8 @@ bl(int arg, int maybe)
void
fixup(STR *str)
{
- register char *s;
- register char *t;
+ char *s;
+ char *t;
for (s = str->str_ptr; *s; s++) {
if (*s == ';' && s[1] == ' ' && s[2] == '\n') {
@@ -1092,8 +1092,8 @@ fixup(STR *str)
void
putlines(STR *str)
{
- register char *d, *s, *t, *e;
- register int pos, newpos;
+ char *d, *s, *t, *e;
+ int pos, newpos;
d = tokenbuf;
pos = 0;
@@ -1168,7 +1168,7 @@ putlines(STR *str)
void
putone(void)
{
- register char *t;
+ char *t;
for (t = tokenbuf; *t; t++) {
*t &= 127;
diff --git a/x2p/hash.c b/x2p/hash.c
index 9cc50f8dba..1620175584 100644
--- a/x2p/hash.c
+++ b/x2p/hash.c
@@ -19,10 +19,10 @@ char *savestr(char *str);
STR *
hfetch(register HASH *tb, char *key)
{
- register char *s;
- register int i;
- register int hash;
- register HENT *entry;
+ char *s;
+ int i;
+ int hash;
+ HENT *entry;
if (!tb)
return NULL;
@@ -45,11 +45,11 @@ hfetch(register HASH *tb, char *key)
bool
hstore(register HASH *tb, char *key, STR *val)
{
- register char *s;
- register int i;
- register int hash;
- register HENT *entry;
- register HENT **oentry;
+ char *s;
+ int i;
+ int hash;
+ HENT *entry;
+ HENT **oentry;
if (!tb)
return FALSE;
@@ -94,12 +94,12 @@ void
hsplit(HASH *tb)
{
const int oldsize = tb->tbl_max + 1;
- register int newsize = oldsize * 2;
- register int i;
- register HENT **a;
- register HENT **b;
- register HENT *entry;
- register HENT **oentry;
+ int newsize = oldsize * 2;
+ int i;
+ HENT **a;
+ HENT **b;
+ HENT *entry;
+ HENT **oentry;
a = (HENT**) saferealloc((char*)tb->tbl_array, newsize * sizeof(HENT*));
memset(&a[oldsize], 0, oldsize * sizeof(HENT*)); /* zero second half */
@@ -130,7 +130,7 @@ hsplit(HASH *tb)
HASH *
hnew(void)
{
- register HASH *tb = (HASH*)safemalloc(sizeof(HASH));
+ HASH *tb = (HASH*)safemalloc(sizeof(HASH));
tb->tbl_array = (HENT**) safemalloc(8 * sizeof(HENT*));
tb->tbl_fill = 0;
diff --git a/x2p/str.c b/x2p/str.c
index d54d08818b..c10e974374 100644
--- a/x2p/str.c
+++ b/x2p/str.c
@@ -22,7 +22,7 @@ str_numset(register STR *str, double num)
char *
str_2ptr(register STR *str)
{
- register char *s;
+ char *s;
if (!str)
return (char *)""; /* probably safe - won't be written to */
@@ -69,7 +69,7 @@ str_nset(register STR *str, register const char *ptr, register int len)
void
str_set(register STR *str, register const char *ptr)
{
- register int len;
+ int len;
if (!ptr)
ptr = "";
@@ -106,7 +106,7 @@ str_scat(STR *dstr, register STR *sstr)
void
str_cat(register STR *str, register const char *ptr)
{
- register int len;
+ int len;
if (!ptr)
return;
@@ -123,7 +123,7 @@ str_cat(register STR *str, register const char *ptr)
STR *
str_new(int len)
{
- register STR *str;
+ STR *str;
if (freestrroot) {
str = freestrroot;
@@ -173,10 +173,10 @@ str_gets(register STR *str, register FILE *fp)
#if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE)
/* Here is some breathtakingly efficient cheating */
- register char *bp; /* we're going to steal some values */
- register int cnt; /* from the stdio struct and put EVERYTHING */
- register STDCHAR *ptr; /* in the innermost loop into registers */
- register char newline = '\n'; /* (assuming at least 6 registers) */
+ char *bp; /* we're going to steal some values */
+ int cnt; /* from the stdio struct and put EVERYTHING */
+ STDCHAR *ptr; /* in the innermost loop into registers */
+ char newline = '\n'; /* (assuming at least 6 registers) */
int i;
int bpx;
@@ -252,7 +252,7 @@ thats_all_folks:
STR *
str_make(const char *s)
{
- register STR *str = str_new(0);
+ STR *str = str_new(0);
str_set(str,s);
return str;
diff --git a/x2p/util.c b/x2p/util.c
index 464dd8f5e9..da17c862df 100644
--- a/x2p/util.c
+++ b/x2p/util.c
@@ -121,8 +121,8 @@ cpy2(register char *to, register char *from, register int delim)
char *
instr(char *big, const char *little)
{
- register char *t, *x;
- register const char *s;
+ char *t, *x;
+ const char *s;
for (t = big; *t; t++) {
for (x=t,s=little; *s; x++,s++) {
@@ -142,7 +142,7 @@ instr(char *big, const char *little)
char *
savestr(const char *str)
{
- register char * const newaddr = (char *) safemalloc((MEM_SIZE)(strlen(str)+1));
+ char * const newaddr = (char *) safemalloc((MEM_SIZE)(strlen(str)+1));
(void)strcpy(newaddr,str);
return newaddr;
diff --git a/x2p/walk.c b/x2p/walk.c
index 03cc5944b5..a92808f432 100644
--- a/x2p/walk.c
+++ b/x2p/walk.c
@@ -42,11 +42,11 @@ char *instr(char *big, const char *little);
STR *
walk(int useval, int level, register int node, int *numericptr, int minprec)
{
- register int len;
- register STR *str;
- register int type;
- register int i;
- register STR *tmpstr;
+ int len;
+ STR *str;
+ int type;
+ int i;
+ STR *tmpstr;
STR *tmp2str;
STR *tmp3str;
char *t;
@@ -1559,7 +1559,7 @@ tab(register STR *str, register int lvl)
static void
fixtab(register STR *str, register int lvl)
{
- register char *s;
+ char *s;
/* strip trailing white space */
@@ -1577,7 +1577,7 @@ fixtab(register STR *str, register int lvl)
static void
addsemi(register STR *str)
{
- register char *s;
+ char *s;
s = str->str_ptr+str->str_cur - 1;
while (s >= str->str_ptr && (*s == ' ' || *s == '\t' || *s == '\n'))
@@ -1589,7 +1589,7 @@ addsemi(register STR *str)
static void
emit_split(register STR *str, int level)
{
- register int i;
+ int i;
if (split_to_array)
str_cat(str,"@Fld");
@@ -1622,9 +1622,9 @@ emit_split(register STR *str, int level)
int
prewalk(int numit, int level, register int node, int *numericptr)
{
- register int len;
- register int type;
- register int i;
+ int len;
+ int type;
+ int i;
int numarg;
int numeric = FALSE;
STR *tmpstr;
@@ -2039,8 +2039,8 @@ prewalk(int numit, int level, register int node, int *numericptr)
static void
numericize(register int node)
{
- register int len;
- register int type;
+ int len;
+ int type;
STR *tmpstr;
STR *tmp2str;
int numarg;