[TYPO3-core] RFC #11746: speed up function t3lib_BEfunc::isRecordLocked()

Rupert Germann rupi at gmx.li
Wed Aug 19 14:03:34 CEST 2009


Oliver Klee schrieb:
> Hi,
> 
> Rupert Germann schrieb:
>> can you explain this further? as far as I see we have only one nesting
>> level.
> 
> Basically, it's like this:
> 
> Change from:
> 
> if (noSpecialCase()) {
>   doLotsOfStuff();
>   result = ...;
> } else {
>   result = shortBitOfCode();
> }
> 
> return result;
> 
> To this:
> 
> if (specialCase()) {
>   return shortBitOfCode();
> }
> 
> doLotsOfStoff();
> result = ...;
> 
> return result;

ahh, ok.
I thought we don't like functions with multiple returns ;-)

seriously: the more common case is, that $LOCKED_RECORDS is already an 
array, so this should be checked first, of course.

would be something like this:

..

$result = FALSE;
if (is_array($LOCKED_RECORDS)) {
    if (isset($LOCKED_RECORDS[$table . ':' . $uid]))  {
       $result = $LOCKED_RECORDS[$table . ':' . $uid];
    }
} else {
    // try to find locked records

    if (isset($LOCKED_RECORDS[$table . ':' . $uid]))  {
       $result = $LOCKED_RECORDS[$table . ':' . $uid];
    }
}
return $result;

..


greets
rupert







More information about the TYPO3-team-core mailing list