Re: cvs: php4 /ext/dba dba.c dba_cdb.c dba_db2.c dba_db3.c dba_dbm.c dba_flatfile.c dba_gdbm.c dba_ndbm.c
| From: | (Marcus Börger) | Date: | Wed, 13 Nov 2002 15:57:28 +0000 |
| Subject: | Re: cvs: php4 /ext/dba dba.c dba_cdb.c dba_db2.c dba_db3.c dba_dbm.c dba_flatfile.c dba_gdbm.c dba_ndbm.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-16093@lists.php.net to get a copy of this message | ||
At 14:14 13.11.2002, Sascha Schumann wrote:
You're right the compiler knows the size in the caller function but not in ecalloc of cause. Shouldn't then ecalloc be a compiler define? #define ecalloc(num, size) \ memset( emalloc(num*size), 0, num*size)Agree but with one single addition if num and size are both constants then the compiler does the multiplication at compiletime. So the above define shouldn't have a run-time multiplication where not necessary.It was like that until Aug 18th. A commit back then turned the fast macro back into a slow function again and added a division. With that kind of setup, the compiler has no chance to reduce and optimize the target code.By using emalloc+memset, we get compile-time reduction (no multiplication at run-time) and inlining for free.- Sascha