Re: Of string constants, bytecode, and concatenation

From: Date: Wed, 26 Feb 2003 17:02:55 +0000
Subject: Re: Of string constants, bytecode, and concatenation
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-94596@lists.php.net to get a copy of this message
On Wed, Feb 26, 2003 at 05:36:54PM +0100, Derick Rethans wrote: | No, the engine doesn't do this at compile time. This first one produces: | | number of ops: 5 | line # op fetch ext operands | ------------------------------------------------------------------------------- | 1 0 CONCAT ~1, 'foo', 'bar' | 1 CONCAT ~2, ~1, 'baz' | 2 FETCH_W local $0, 's1' | 3 ASSIGN $3, $0, ~2 | 3 4 RETURN 1 | | The second one: | | line # op fetch ext operands | ------------------------------------------------------------------------------- | 1 0 FETCH_W local $0, 's2' | 1 ASSIGN $1, $0, 'foobarbaz' | 2 2 RETURN 1 Is that output a ZEND_DEBUG thing, or is that an external tool? | > If not, can anyone explain the barriers to doing something like this? | | It's the job of an optimizer, not of a compiler. And because PHP doesn't | have an internal optimizer, this is not optimized out. You can either Okay. Makes complete sense. I was thinking more along the lines of "wouldn't it be nice if...?". I hadn't quite made it to "where would that belong?". :) I'll check out the optimizers. I noticed that the new CVS version of APC seems to have a configuration option for optimization as well, though I'm not sure how far along it is. Thanks again, - Dave dave@codewhore.org

« previous php.dev (#94596) next »