diff options
author | Karl Williamson <public@khwilliamson.com> | 2012-08-16 10:50:14 -0600 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2012-08-18 11:26:37 -0600 |
commit | eb578fdb5569b91c28466a4d1939e381ff6ceaf4 (patch) | |
tree | cb76dfdd15ead716ff76b6a46eb1c49f10b302f2 /x2p/str.c | |
parent | 29205e9cdf0a179ed7a2e9401a3b19c8ede062db (diff) | |
download | perl-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/str.c')
-rw-r--r-- | x2p/str.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -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; |