Home »
General »
PHP discussions »
Brain deadness of PHP
Brain deadness of PHP [message #2119] |
Wed, 01 May 2002 01:43 ![Go to next message Go to next message](/forum/theme/default/images/down.png) |
Ilia
![Canada Canada](/forum/images/flags/ca.png) Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
"substr_replace" function was introduced a while back into PHP, in theory it is a wonderful function that allows the user to replace a section of the string with another.
Well, today while coding FUDcode parser, I decided to use that function , I should've known better.
After spending over 1 hour trying to trace the reason behind the slowness of my code I found out that substr_replace function is EXTREMLY slow and becomes exponentially slower as the string size increases. Now the "funny" part using php code I was able to write the same function which was in excess of 100% faster!!!! This should give you some idea as to how badly that function is written, since it is written in C and not PHP, hence should be @ least 10 times faster then anything I write in PHP.
</rantoff>
Moral of this story, DO NOT use substr_replace!
FUDforum Core Developer
|
|
|
|
|
|
|
Re: Brain deadness of PHP [message #15374 is a reply to message #15373] |
Fri, 12 December 2003 17:21 ![Go to previous message Go to previous message](/forum/theme/default/images/up.png) |
Ilia
![Canada Canada](/forum/images/flags/ca.png) Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
That's ok, I've already rewritten PHP's substr_replace function and it'll works nice and fast as of version 4.3.5 (soon to be released).
FUDforum Core Developer
|
|
|
Goto Forum:
Current Time: Tue Feb 18 19:33:56 GMT 2025
Total time taken to generate the page: 0.03459 seconds