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 /malloc.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 'malloc.c')
-rw-r--r-- | malloc.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -1263,8 +1263,8 @@ Malloc_t Perl_malloc(size_t nbytes) { dVAR; - register union overhead *p; - register int bucket; + union overhead *p; + int bucket; #if defined(DEBUGGING) || defined(RCHECK) MEM_SIZE size = nbytes; @@ -1681,10 +1681,10 @@ static void morecore(register int bucket) { dVAR; - register union overhead *ovp; - register int rnu; /* 2^rnu bytes will be requested */ + union overhead *ovp; + int rnu; /* 2^rnu bytes will be requested */ int nblks; /* become nblks blocks of the desired size */ - register MEM_SIZE siz, needed; + MEM_SIZE siz, needed; static int were_called = 0; if (nextf[bucket]) @@ -1816,8 +1816,8 @@ Free_t Perl_mfree(Malloc_t where) { dVAR; - register MEM_SIZE size; - register union overhead *ovp; + MEM_SIZE size; + union overhead *ovp; char *cp = (char*)where; #ifdef PACK_MALLOC u_char bucket; @@ -1912,11 +1912,11 @@ Malloc_t Perl_realloc(void *mp, size_t nbytes) { dVAR; - register MEM_SIZE onb; + MEM_SIZE onb; union overhead *ovp; char *res; int prev_bucket; - register int bucket; + int bucket; int incr; /* 1 if does not fit, -1 if "easily" fits in a smaller bucket, otherwise 0. */ char *cp = (char*)mp; @@ -2188,8 +2188,8 @@ int Perl_get_mstats(pTHX_ perl_mstats_t *buf, int buflen, int level) { #ifdef DEBUGGING_MSTATS - register int i, j; - register union overhead *p; + int i, j; + union overhead *p; struct chunk_chain_s* nextchain; PERL_ARGS_ASSERT_GET_MSTATS; @@ -2250,7 +2250,7 @@ void Perl_dump_mstats(pTHX_ const char *s) { #ifdef DEBUGGING_MSTATS - register int i; + int i; perl_mstats_t buffer; UV nf[NBUCKETS]; UV nt[NBUCKETS]; |