Revert "[TASK] Avoid slow array functions in loops"
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Routing / Enhancer / VariableProcessor.php
index 75e46c2..6bc8838 100644 (file)
@@ -340,19 +340,22 @@ class VariableProcessor
             $prefix .= static::LEVEL_DELIMITER;
         }
 
-        $result = [[]];
+        $result = [];
         foreach ($array as $key => $value) {
             if (is_array($value)) {
-                $result[] = $this->deflateArray(
-                    $value,
-                    $prefix . $key . static::LEVEL_DELIMITER
+                $result = array_merge(
+                    $result,
+                    $this->deflateArray(
+                        $value,
+                        $prefix . $key . static::LEVEL_DELIMITER
+                    )
                 );
             } else {
                 $deflatedKey = $this->addHash($prefix . $key);
-                $result[] = [$deflatedKey => $value];
+                $result[$deflatedKey] = $value;
             }
         }
-        return array_merge(...$result);
+        return $result;
     }
 
     /**