Re: [PHP-DEV] Calling symbol table patch From: Andi Gutmans (andi <email protected>)
Date: 11/21/00

At together all of the "Oh, come on"'s we had about adding unnecessary code
in that area of execute() and you'll get a serious slow down.
Not only does this patch get into that category, it's also IMO bad coding
to rely on such a feature.

Andi

At 03:34 PM 11/20/00 -0600, Andrei Zmievski wrote:
>On Mon, 20 Nov 2000, Zeev Suraski wrote:
> > Well, a stack push is a considerable slowdown. How much it slows things
> > down exactly obviously depends on your script...
>
>Oh, come on.
>
>ZEND_API inline void zend_ptr_stack_push(zend_ptr_stack *stack, void *ptr)
>{
> if (stack->top >= stack->max) { /* we need to allocate more memory */
> stack->elements = (void **) erealloc(stack->elements,
> (sizeof(void *) * (stack->max *= 2 )));
> stack->top_element = stack->elements+stack->top;
> }
> stack->top++;
> *(stack->top_element++) = ptr;
>}
>
>Most of the time, stack->top is less than stack->max (because max = 64
>on initialization), so all you are executing is the last two statements.
>
>I don't think your argument is very strong as far as performance is
>concerned.
>
> > I think that the Right Way to do it would actually be a function that
> > returns the current symbol table. Such a function can be implemented
> > without slowing down or modifying anything in the engine, and then you
> > could write:
> >
> > $tpl->batch_assign('foo', 'bar', 'color1', get_active_symtable())
> >
> > It's a bit more to type, no doubt, but I think it's more correct that
> > way... Perhaps one day we'll have macros in PHP :)
> >
> > What I don't like about the function is that it appears to be hacky - it
> > defeats a basic scope protection rule in structured/OO programming...
>
>Yes, it does, but the only way around it is what you described up above
>and it doesn't really look that appealing. If it was C/C++, I could
>write a macro or something else, but with PHP, we don't have that. So,
>I'm not sure what the solution is.
>
>-Andrei
>
>What's hard, in hacking as in fiction,
>is not the writing, it's deciding what to write.
> -- Neal Stephenson

---
Andi Gutmans <andi <email protected>>
http://www.zend.com/

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>