Skip to content

Commit 9c42b97

Browse files
authored
Merge pull request #7949 from magento-performance/ACPT-809
ACPT-809: [Community] #36276 Long time request execution
2 parents 093ddc6 + 1835679 commit 9c42b97

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/ProductDataMapper.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,11 @@ private function getValuesLabels(Attribute $attribute, array $attributeValues, i
370370
return $attributeLabels;
371371
}
372372

373+
// array_flip() + foreach { isset() } is much faster than foreach { in_array() } when there are many options
374+
$attributeValues = array_flip($attributeValues);
375+
373376
foreach ($options as $option) {
374-
if (\in_array($option['value'], $attributeValues)) {
377+
if (isset($attributeValues[$option['value']])) {
375378
$attributeLabels[] = $option['label'];
376379
}
377380
}

lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ class ServiceInputProcessor implements ServicePayloadConverterInterface
101101
*/
102102
private $defaultPageSizeSetter;
103103

104+
/**
105+
* @var array
106+
*/
107+
private $methodReflectionStorage = [];
108+
104109
/**
105110
* Initialize dependencies.
106111
*
@@ -153,6 +158,7 @@ public function __construct(
153158
* @return \Magento\Framework\Reflection\NameFinder
154159
*
155160
* @deprecated 100.1.0
161+
* @see nothing
156162
*/
157163
private function getNameFinder()
158164
{
@@ -260,6 +266,7 @@ private function getConstructorData(string $className, array $data): array
260266
* @return object the newly created and populated object
261267
* @throws \Exception
262268
* @throws SerializationException
269+
* @SuppressWarnings(PHPMD.NPathComplexity)
263270
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
264271
*/
265272
protected function _createFromArray($className, $data)
@@ -287,7 +294,10 @@ protected function _createFromArray($className, $data)
287294
// This use case is for REST only. SOAP request data is already camel cased
288295
$camelCaseProperty = SimpleDataObjectConverter::snakeCaseToUpperCamelCase($propertyName);
289296
$methodName = $this->getNameFinder()->getGetterMethodName($class, $camelCaseProperty);
290-
$methodReflection = $class->getMethod($methodName);
297+
if (!isset($this->methodReflectionStorage[$className . $methodName])) {
298+
$this->methodReflectionStorage[$className . $methodName] = $class->getMethod($methodName);
299+
}
300+
$methodReflection = $this->methodReflectionStorage[$className . $methodName];
291301
if ($methodReflection->isPublic()) {
292302
$returnType = $this->typeProcessor->getGetterReturnType($methodReflection)['type'];
293303
try {

0 commit comments

Comments
 (0)