friendica/friendica — pull request #601 by fermionic (2013-02-05 03:23:48+00:00)
Title: move mb_strlen call out of for loop definition

I was getting php-fpm processes that would use 100% of the CPU for an hour or more frequently after the poller ran for a user who posted a huge post (~1,000,000 characters -- it had a lot of embedded photos in it). I traced it to the `mb_strlen()` call in the `xmlify()` function, but couldn't figure out exactly what the problem was further than that.

I tried moving the call to `mb_strlen()` out of the for loop definition into a variable and that seemed to fix it. I'm not sure why; my best guess (which I've been unable to confirm with a quick look on Startpage) is that the exit condition of the for loop is checked on every loop, which would be a very large hit for a large post. At any rate, there shouldn't be any harm in doing this and it seems to have fixed it--I haven't seen any 100% loops since I made the change, anyway.