Re: [ZEND-ENGINE-CVS] cvs: Zend / zend_alloc.c zend_alloc.h
| From: | Stefan Esser | Date: | Wed, 21 Aug 2002 07:32:50 +0000 |
| Subject: | Re: [ZEND-ENGINE-CVS] cvs: Zend / zend_alloc.c zend_alloc.h | ||
| References: | 1 2 3 | Groups: | php.zend-engine.cvs |
| Request: | Send a blank email to php-zend-engine-cvs+get-340@lists.php.net to get a copy of this message | ||
> > Can't you think of a faster way than using division? I bet there's a better
> > way.
If you consider that one integer division compared to the whole overhead
of calling (e)malloc is nothing I doubt another way is needed.
Another way would be to first check if both operands are below half of
size_t (16 bit) (!((nmemb|size)&0xFFFF0000) but that is harder to
implement because of 64 bit compatibility... Or Do we have constants
for this already??? another way is to count the
bits... if they are /8 < sizeof (size_t) then there will be no integer
overflow... But this will need several loop+shift operations...
I would be really suprised if that is still faster than a single
integer division.
> maybe we should get rid of ecalloc in ZE2 completely?
What is the problem with ecalloc? If you think it is too slow you can
use emalloc+memset. Infact there are only a few places in php where
it is used at all... So speed is not really sooo important.
Stefan