Re: RFC: mark functions as const for possible optimizations

From: Date: Mon, 17 Sep 2007 13:45:04 +0000
Subject: Re: RFC: mark functions as const for possible optimizations
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-32359@lists.php.net to get a copy of this message
I had a quick question about this. When would strlen('abcd') be execuated? Say I had the code: $a = false; // This set by external input if ( $a ) $b = strlen('abcd'); Would the optimizer work out the length before the program starts to run? Or would the optimizer wait until it knows the strlen is going to be called then convert it to the constant 4?
That's not my problem.. My RFC is about making the information available, not writing the optimizer itself (at least for now). With a naive optimizer, strlen() would be called, yes.
I could see the optimizer "constifying" many function calls which will never get called.
that's not a problem since you would use a cache.. Nuno

« previous php.internals (#32359) next »