At 03:11 PM 7/30/2004 -0400, Robert Cummings wrote:
On Fri, 2004-07-30 at 13:11, Andi Gutmans wrote:
> Rob,
>
> First of all I don't know where you are getting O(n) from because the
> operation is O(1).
> Secondly, I just don't understand what the sudden necessity for the goto
> construct is when over the years we have barely ever had a PHP developer
> asking for it.
> And please guys, don't use C optimization comparisons as an example. This
> doesn't apply to PHP...

Goto is O(1) -- cascading through switch cases till you hit the right
one is O(n) where there are n possible cases. Now if I have to run
through that damn switch time m times, then my runtime is O(mn) whereas
with goto it's O(m). This isn't a C optimization, this is just the best
way to do it sometimes. Even if goto was a runtime lookup I'm still
better off with O(m lg n).

But you have break n in PHP. I guess we are talking about different things. Can you show me an example of when it'd be O(n)?


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to