Oh well, I knew this wouldn't generate any comments... ::)
Anyway, I'm currently working on this. Trying to optimize parse_bbc() as well -- the folly!!
Heck, I've even created a static array, $strlower, which holds a lowercase version of the ASCII table, just to optimize ONE call to strtolower() that gets executed on each new tag found... It's probably a bit TOO silly -- although this call is now a whopping 3 times faster... Uh.
I'm also considering something else that could be a much better improvement.
Say we do, at SMF import time, a conversion of all tags to lowercase...
Now, in preparsecode(), we convert all tags to lowercase just the same.
See what I mean...? parse_bbc() suddenly no longer has to care for strtolower or stripos. And believe me, stripos is used quite a lot of time, and I know from experience that it's nearly as slow as doing a strpos(strtolower())...
What do you think?
Posted: May 26th, 2012, 07:33 PM
Also... Maybe we could store strlen($tag) inside the database...? It would save us a call to strlen() for each and every possible tag being tested against... (Heck, it would probably even be faster to just calculate and store the strlen in the bbcode cache at the beginning of the function... Because, let's say you have dozens of "tt" tags in your post: for each of them, it'll be calculating strlen('table'), strlen('td'), strlen('time'), strlen('tr') and strlen('tt')... Funny hey?)
I did a few tests earlier and the only offenders were the Aeva and media tags actually...
Posted: May 26th, 2012, 09:43 PM
Shall I keep the strlen db cache then btw?