[TASK] Use direct array assignments instead of array_push 49/52049/4
authorCedric Ziel <cedric@cedric-ziel.com>
Wed, 15 Mar 2017 09:36:14 +0000 (10:36 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 28 Mar 2017 17:27:26 +0000 (19:27 +0200)
Direct assignments are usually 2x faster and often more readable
when pushing one value only.

Releases: master
Fixes: #80283
Change-Id: I16fc1938f74550d1a3d9f9c0cbafe85dc2ff1c5b
Reviewed-on: https://review.typo3.org/52049
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
16 files changed:
typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php
typo3/sysext/core/Classes/Charset/CharsetConverter.php
typo3/sysext/core/Classes/Html/HtmlParser.php
typo3/sysext/core/Classes/Service/AbstractService.php
typo3/sysext/core/Classes/Service/DependencyOrderingService.php
typo3/sysext/core/Classes/TimeTracker/TimeTracker.php
typo3/sysext/core/Classes/Utility/RootlineUtility.php
typo3/sysext/extbase/Classes/Error/Result.php
typo3/sysext/extbase/Classes/Scheduler/FieldProvider.php
typo3/sysext/extbase/Classes/Scheduler/Task.php
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example/Configuration/TCA/Overrides/fe_users.php
typo3/sysext/extensionmanager/Classes/Utility/DependencyUtility.php
typo3/sysext/frontend/Classes/ContentObject/LoadRegisterContentObject.php
typo3/sysext/frontend/Classes/Controller/TranslationStatusController.php
typo3/sysext/recordlist/Classes/LinkHandler/PageLinkHandler.php
typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php

index 2a2884e..7220404 100644 (file)
@@ -401,12 +401,9 @@ class FormInlineAjaxController extends AbstractFormEngineAjaxController
             }
             // Tell JS to add new HTML of one or multiple (localize all) records to DOM
             if (!empty($jsonArray['data'])) {
-                array_push(
-                    $jsonArray['scriptCall'],
-                    'inline.domAddNewRecord(\'bottom\', ' . GeneralUtility::quoteJSvalue($nameObject . '_records')
-                    . ', ' . GeneralUtility::quoteJSvalue($nameObjectForeignTable)
-                    . ', json.data);'
-                );
+                $jsonArray['scriptCall'][] = 'inline.domAddNewRecord(\'bottom\', ' . GeneralUtility::quoteJSvalue($nameObject . '_records')
+                . ', ' . GeneralUtility::quoteJSvalue($nameObjectForeignTable)
+                . ', json.data);';
             }
         }
 
index 7c633d0..01c4e9c 100644 (file)
@@ -979,7 +979,7 @@ class CharsetConverter implements SingletonInterface
                     }
                 } elseif (!isset($mark['U+' . $code_value])) {
                     // remove mark
-                    array_push($code_decomp, $code_value);
+                    $code_decomp[] = $code_value;
                 }
             }
             if (!empty($code_decomp) || isset($omit[$from])) {
@@ -999,7 +999,7 @@ class CharsetConverter implements SingletonInterface
                     continue 2;
                 } else {
                     // Skip decompositions containing non-ASCII chars
-                    array_push($code_decomp, chr($ord));
+                    $code_decomp[] = chr($ord);
                 }
             }
             $ascii[$this->UnumberToChar(hexdec($from))] = implode('', $code_decomp);
index 3402cf9..e3cccec 100644 (file)
@@ -611,9 +611,9 @@ class HtmlParser
                                             }
                                         }
                                     } else {
-                                        array_push($tagRegister[$tagName], $c);
+                                        $tagRegister[$tagName][] = $c;
                                         if ($tags[$tagName]['nesting'] === 'global') {
-                                            array_push($tagStack, $tagName);
+                                            $tagStack[] = $tagName;
                                         }
                                     }
                                 }
index a58b474..1ccd225 100644 (file)
@@ -164,7 +164,7 @@ abstract class AbstractService
      */
     public function errorPush($errNum = T3_ERR_SV_GENERAL, $errMsg = 'Unspecified error occurred')
     {
-        array_push($this->error, ['nr' => $errNum, 'msg' => $errMsg]);
+        $this->error[] = ['nr' => $errNum, 'msg' => $errMsg];
         /** @var \TYPO3\CMS\Core\TimeTracker\TimeTracker $timeTracker */
         $timeTracker = GeneralUtility::makeInstance(TimeTracker::class);
         $timeTracker->setTSlogMessage($errMsg, 2);
index 62798e3..df5de9c 100644 (file)
@@ -157,7 +157,7 @@ class DependencyOrderingService
             }
             unset($rootIds[$currentId]);
 
-            array_push($sortedIds, $currentId);
+            $sortedIds[] = $currentId;
 
             // Process the dependencies of the current node
             foreach (array_filter($dependencyGraph[$currentId]) as $dependingId => $_) {
index 4b56019..14bf30c 100644 (file)
@@ -163,8 +163,8 @@ class TimeTracker implements SingletonInterface
         if (!$this->isEnabled) {
             return;
         }
-        array_push($this->tsStack[$this->tsStackPointer], $tslabel);
-        array_push($this->currentHashPointer, 'timetracker_' . $this->uniqueCounter++);
+        $this->tsStack[$this->tsStackPointer][] = $tslabel;
+        $this->currentHashPointer[] = 'timetracker_' . $this->uniqueCounter++;
         $this->tsStackLevel++;
         $this->tsStackLevelMax[] = $this->tsStackLevel;
         // setTSlog
index 1c27eaa..a182cb5 100644 (file)
@@ -416,7 +416,7 @@ class RootlineUtility
         } else {
             $rootline = [];
         }
-        array_push($rootline, $page);
+        $rootline[] = $page;
         krsort($rootline);
         static::$cache->set($this->cacheIdentifier, $rootline, $cacheTags);
         static::$localCache[$this->cacheIdentifier] = $rootline;
index df5ee68..7a3d8d1 100644 (file)
@@ -422,7 +422,7 @@ class Result
             $result[implode('.', $level)] = $this->$propertyName;
         }
         foreach ($this->propertyResults as $subPropertyName => $subResult) {
-            array_push($level, $subPropertyName);
+            $level[] = $subPropertyName;
             $subResult->flattenTree($propertyName, $result, $level);
             array_pop($level);
         }
index 50689c0..b65b8d1 100644 (file)
@@ -302,9 +302,9 @@ class FieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInter
         ];
         foreach ($options as $optionValue => $optionLabel) {
             $selected = $optionValue === $selectedOptionValue ? ' selected="selected"' : '';
-            array_push($html, '<option title="test" value="' . htmlspecialchars($optionValue) . '"' . $selected . '>' . htmlspecialchars($optionLabel) . '</option>');
+            $html[] = '<option title="test" value="' . htmlspecialchars($optionValue) . '"' . $selected . '>' . htmlspecialchars($optionLabel) . '</option>';
         }
-        array_push($html, '</select>');
+        $html[] = '</select>';
         return implode(LF, $html);
     }
 
index bd81c92..aeb97a4 100644 (file)
@@ -174,7 +174,7 @@ class Task extends \TYPO3\CMS\Scheduler\Task\AbstractTask
             $arguments = [];
             foreach ($this->arguments as $argumentName => $argumentValue) {
                 if ($argumentValue != $this->defaults[$argumentName]) {
-                    array_push($arguments, $argumentName . '=' . $argumentValue);
+                    $arguments[] = $argumentName . '=' . $argumentValue;
                 }
             }
             $label .= ' ' . implode(', ', $arguments);
index a2257c7..48a0403 100644 (file)
@@ -3,5 +3,5 @@ defined('TYPO3_MODE') or die();
 
 if (is_array($GLOBALS['TCA']['fe_users']['columns']['tx_extbase_type'])) {
     $GLOBALS['TCA']['fe_users']['types']['Tx_BlogExample_Domain_Model_Administrator'] = $GLOBALS['TCA']['fe_users']['types']['0'];
-    array_push($GLOBALS['TCA']['fe_users']['columns']['tx_extbase_type']['config']['items'], ['LLL:EXT:blog_example/Resources/Private/Language/locallang_db.xml:fe_users.tx_extbase_type.Tx_BlogExample_Domain_Model_Administrator', 'Tx_BlogExample_Domain_Model_Administrator']);
+    $GLOBALS['TCA']['fe_users']['columns']['tx_extbase_type']['config']['items'][] = ['LLL:EXT:blog_example/Resources/Private/Language/locallang_db.xml:fe_users.tx_extbase_type.Tx_BlogExample_Domain_Model_Administrator', 'Tx_BlogExample_Domain_Model_Administrator'];
 }
index 265629f..77e6bfd 100644 (file)
@@ -592,7 +592,7 @@ class DependencyUtility implements \TYPO3\CMS\Core\SingletonInterface
                 if ($dependency->getIdentifier() === 'typo3') {
                     try {
                         if ($this->checkTypo3Dependency($dependency)) {
-                            array_push($suitableExtensions, $extension);
+                            $suitableExtensions[] = $extension;
                         }
                     } catch (Exception\UnresolvedTypo3DependencyException $e) {
                     }
index 9892376..812fe44 100644 (file)
@@ -28,7 +28,7 @@ class LoadRegisterContentObject extends AbstractContentObject
      */
     public function render($conf = [])
     {
-        array_push($GLOBALS['TSFE']->registerStack, $GLOBALS['TSFE']->register);
+        $GLOBALS['TSFE']->registerStack[] = $GLOBALS['TSFE']->register;
         if (is_array($conf)) {
             $isExecuted = [];
             foreach ($conf as $theKey => $theValue) {
index 05154cf..8823cb3 100644 (file)
@@ -303,7 +303,7 @@ class TranslationStatusController extends \TYPO3\CMS\Backend\Module\AbstractFunc
                 if (!empty($newOL_js[$langRow['uid']])) {
                     $onClickArray = explode('?', $onClick, 2);
                     $lastElement = array_pop($onClickArray);
-                    array_push($onClickArray, '\'' . $newOL_js[$langRow['uid']] . ' + \'&' . $lastElement);
+                    $onClickArray[] = '\'' . $newOL_js[$langRow['uid']] . ' + \'&' . $lastElement;
                     $onClick = implode('?', $onClickArray);
                 }
                 $newButton = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($onClick)
index b9f723f..4c6358f 100644 (file)
@@ -306,7 +306,7 @@ class PageLinkHandler extends AbstractLinkHandler implements LinkHandlerInterfac
     {
         $configuration = $this->linkBrowser->getConfiguration();
         if (!empty($configuration['pageIdSelector.']['enabled'])) {
-            array_push($this->linkAttributes, 'pageIdSelector');
+            $this->linkAttributes[] = 'pageIdSelector';
             $fieldDefinitions['pageIdSelector'] = '
                                <tr>
                                        <td>
index 0ab504d..2d0f783 100644 (file)
@@ -506,7 +506,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList
         $rowListArray = GeneralUtility::trimExplode(',', $rowList, true);
         // if no columns have been specified, show description (if configured)
         if (!empty($GLOBALS['TCA'][$table]['ctrl']['descriptionColumn']) && empty($rowListArray)) {
-            array_push($rowListArray, $GLOBALS['TCA'][$table]['ctrl']['descriptionColumn']);
+            $rowListArray[] = $GLOBALS['TCA'][$table]['ctrl']['descriptionColumn'];
         }
         $backendUser = $this->getBackendUserAuthentication();
         $lang = $this->getLanguageService();
@@ -1126,7 +1126,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList
                         $onClick = BackendUtility::editOnClick('', '', -1);
                         $onClickArray = explode('?', $onClick, 2);
                         $lastElement = array_pop($onClickArray);
-                        array_push($onClickArray, $params . '&' . $lastElement);
+                        $onClickArray[] = $params . '&' . $lastElement;
                         $onClick = implode('?', $onClickArray);
                         $cells['edit'] = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
                             . htmlspecialchars($lang->getLL('clip_editMarked')) . '">'
@@ -1215,7 +1215,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList
                             $onClick = BackendUtility::editOnClick('', '', -1);
                             $onClickArray = explode('?', $onClick, 2);
                             $lastElement = array_pop($onClickArray);
-                            array_push($onClickArray, $params . '&' . $lastElement);
+                            $onClickArray[] = $params . '&' . $lastElement;
                             $onClick = implode('?', $onClickArray);
                             $icon .= '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick)
                                 . '" title="' . htmlspecialchars($lang->getLL('editShownColumns')) . '">'
@@ -1261,7 +1261,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList
                             $onClick = BackendUtility::editOnClick('', '', -1);
                             $onClickArray = explode('?', $onClick, 2);
                             $lastElement = array_pop($onClickArray);
-                            array_push($onClickArray, $params . '&' . $lastElement);
+                            $onClickArray[] = $params . '&' . $lastElement;
                             $onClick = implode('?', $onClickArray);
                             $iTitle = sprintf($lang->getLL('editThisColumn'), $sortLabel);
                             $theData[$fCol] .= '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick)