Skip to content

Commit 4c2cb0c

Browse files
authored
ENGCOM-9121: Generator matching optimization #31613
2 parents 8acba07 + 2ba497e commit 4c2cb0c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: lib/internal/Magento/Framework/Code/Generator.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ public function generateClass($className)
105105
$resultEntityType = null;
106106
$sourceClassName = null;
107107
foreach ($this->_generatedEntities as $entityType => $generatorClass) {
108+
$suffixLen = strlen($entityType);
108109
$entitySuffix = ucfirst($entityType);
109110
// If $className string ends with $entitySuffix substring
110-
if (strrpos($className, $entitySuffix) === strlen($className) - strlen($entitySuffix)) {
111+
if (substr_compare($className, $entitySuffix, -$suffixLen, $suffixLen) == 0) {
111112
$resultEntityType = $entityType;
112113
$sourceClassName = rtrim(
113-
substr($className, 0, -1 * strlen($entitySuffix)),
114+
substr($className, 0, -$suffixLen),
114115
'\\'
115116
);
116117
break;

0 commit comments

Comments
 (0)