Skip to content

Commit 30db7cd

Browse files
author
Stanislav Idolov
authored
ENGCOM-2113: [Backport] array_push(...) calls behaving as '$array[] = ...', $array[] = works faster than invoking functions in PHP #16359
2 parents c20946e + 7122a88 commit 30db7cd

File tree

9 files changed

+15
-15
lines changed

9 files changed

+15
-15
lines changed

app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ protected function orderCountryOptions(array $countryOptions)
377377
]];
378378
foreach ($countryOptions as $countryOption) {
379379
if (empty($countryOption['value']) || in_array($countryOption['value'], $this->topCountryCodes)) {
380-
array_push($headOptions, $countryOption);
380+
$headOptions[] = $countryOption;
381381
} else {
382-
array_push($tailOptions, $countryOption);
382+
$tailOptions[] = $countryOption;
383383
}
384384

385385
}

app/code/Magento/Checkout/Block/Checkout/DirectoryDataProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ private function orderCountryOptions(array $countryOptions)
136136
]];
137137
foreach ($countryOptions as $countryOption) {
138138
if (empty($countryOption['value']) || in_array($countryOption['value'], $topCountryCodes)) {
139-
array_push($headOptions, $countryOption);
139+
$headOptions[] = $countryOption;
140140
} else {
141-
array_push($tailOptions, $countryOption);
141+
$tailOptions[] = $countryOption;
142142
}
143143
}
144144
return array_merge($headOptions, $tailOptions);

app/code/Magento/ImportExport/Model/Report/Csv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function createReport(
7777
$outputCsv = $this->createOutputCsvModel($outputFileName);
7878

7979
$columnsName = $sourceCsv->getColNames();
80-
array_push($columnsName, self::REPORT_ERROR_COLUMN_NAME);
80+
$columnsName[] = self::REPORT_ERROR_COLUMN_NAME;
8181
$outputCsv->setHeaderCols($columnsName);
8282

8383
foreach ($sourceCsv as $rowNum => $rowData) {

app/code/Magento/Quote/Model/Quote.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@ public function getErrors()
20012001
foreach ($this->getMessages() as $message) {
20022002
/* @var $error \Magento\Framework\Message\AbstractMessage */
20032003
if ($message->getType() == \Magento\Framework\Message\MessageInterface::TYPE_ERROR) {
2004-
array_push($errors, $message);
2004+
$errors[] = $message;
20052005
}
20062006
}
20072007
return $errors;

app/code/Magento/SalesRule/Model/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ public function sortItemsByPriority($items, Address $address = null)
508508
foreach ($items as $itemKey => $itemValue) {
509509
if ($rule->getActions()->validate($itemValue)) {
510510
unset($items[$itemKey]);
511-
array_push($itemsSorted, $itemValue);
511+
$itemsSorted[] = $itemValue;
512512
}
513513
}
514514
}

lib/internal/Magento/Framework/Webapi/Rest/Response/FieldsFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ protected function parse($filterString)
104104
}
105105
switch ($filterString[$position]) {
106106
case '[':
107-
array_push($parent, $currentElement);
107+
$parent[] = $currentElement;
108108
// push current field in stack and initialize current
109-
array_push($stack, $current);
109+
$stack[] = $current;
110110
$current = [];
111111
break;
112112

setup/src/Magento/Setup/Module/Dependency/Circular.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ protected function buildCircular($modules)
118118
return;
119119
}
120120
$this->circularDependencies[$path] = $modules;
121-
array_push($modules, array_shift($modules));
121+
$modules[] = array_shift($modules);
122122
$this->buildCircular($modules);
123123
}
124124

@@ -133,7 +133,7 @@ protected function divideByModules($circularDependencies)
133133
$dependenciesByModule = [];
134134
foreach ($circularDependencies as $circularDependency) {
135135
$module = $circularDependency[0];
136-
array_push($circularDependency, $module);
136+
$circularDependency[] = $module;
137137
$dependenciesByModule[$module][] = $circularDependency;
138138
}
139139

setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlInterceptorScanner.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ protected function _collectEntitiesFromString($content)
4242
$attributes = $entityNode->attributes;
4343
$type = $attributes->getNamedItem('type');
4444
if ($type !== null) {
45-
array_push($output, $type->nodeValue);
45+
$output[] = $type->nodeValue;
4646
} else {
47-
array_push($output, $attributes->getNamedItem('name')->nodeValue);
47+
$output[] = $attributes->getNamedItem('name')->nodeValue;
4848
}
4949
}
5050
return $output;
@@ -80,7 +80,7 @@ protected function _filterEntities(array $output)
8080
$this->_handleControllerClassName($entityName);
8181
}
8282
if (class_exists($entityName) || interface_exists($entityName)) {
83-
array_push($filteredEntities, $entityName . '\\Interceptor');
83+
$filteredEntities[] = $entityName . '\\Interceptor';
8484
}
8585
}
8686
return $filteredEntities;

setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlScanner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function _filterEntities(array $output)
7272
}
7373
if (false === $isClassExists) {
7474
if (class_exists($entityName) || interface_exists($entityName)) {
75-
array_push($filteredEntities, $className);
75+
$filteredEntities[] = $className;
7676
} else {
7777
$this->_log->add(
7878
\Magento\Setup\Module\Di\Compiler\Log\Log::CONFIGURATION_ERROR,

0 commit comments

Comments
 (0)