[TYPO3-core] GeneralUtility::inList() and spaces

JoH asenau info at cybercraft.de
Tue Jul 16 11:22:44 CEST 2013


Am 10.07.2013 12:15, schrieb François Suter:
> Hi Markus,
>
>> I suggest to use "the middle way" and just do a trim() on the values,
>> which still does the trick without RegExp.
>
> That's what I thought too, but inList() doesn't explode the string. It
> just does:
>
> return strpos(',' . $list . ',', ',' . $item . ',') !== FALSE ? TRUE :
> FALSE;
>
> So again, exploding the string and trimming its components is much more
> work than using strpos(). I don't know what the performance impact could
> be, given that it's such a widespread method.

Well, my personal experience is, that in PHP most of the string 
functions are much slower than array functions. Which is why we went for 
i.e. array_intersect_key while coding the stdWrap stuff for 4.5.

Since we just have to check, if a string is there at all, without caring 
about the other strings and the position within the list, explode should 
be the way to go, according to these benchmarks:

http://www.werbe-markt.de/php-optimierung-strings-durchsuchen-vor-zerlegen.php

Just my 2 cents

Joey

-- 
Wenn man keine Ahnung hat: Einfach mal Fresse halten!
(If you have no clues: simply shut your gob sometimes!)
Dieter Nuhr, German comedian
Xing: http://contact.cybercraft.de
Twitter: http://twitter.com/bunnyfield
TYPO3 cookbook (2nd edition): http://www.typo3experts.com


More information about the TYPO3-team-core mailing list