[TYPO3-core] RFC #15002: Enhancement of t3lib_div::isFirstPartOfStr
Michiel Roos [netcreators]
michiel at netcreators.com
Mon Jul 5 17:42:28 CEST 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 7/5/10 12:36 PM, Jigal van Hemert wrote:
> Can't we clean-up the code a bit? :
> - have a single return
No, please see attached tests that include two versions using a single
return. Both are slower than the original proposal.
We can slim the function down to two lines at the cost of readability:
function isFirstPartOfStrNew ($str, $partStr) {
if ($partStr === '') return FALSE;
return (strpos($str, $partStr, 0) === 0) ? TRUE : FALSE;
}
Hmm, tests show that that is also slower (and less readable).
> - use CGL (TRUE instead of true; spaces after ',' in function arguments;
> space before '{' instead of tab, etc.)
Please find a v2 attached that also addresses the CGL issues.
And also a new test file.
>
> Other than that,
> +1 by reading and testing
>
- --
Met vriendelijke groet / Warm regards,
Michiel Roos
Chief Technical Officer
Netcreators: Open Source, Open Minds, Open People
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkwx/VwACgkQLMRd8N/xuizfuwCgy7/ka3c2vHvAvQQkvrW7QoE3
Kc4Anjl0DhCjyRHGc4Vl7RmXJgZg0iKY
=hha1
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 15002_v2.diff
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20100705/18fc68b4/attachment.asc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 15002_test_v3.php
Type: text/php
Size: 3376 bytes
Desc: not available
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20100705/18fc68b4/attachment.bin>
More information about the TYPO3-team-core
mailing list