Skip to content

Commit c216bb4

Browse files
authored
Perf: Keep catalogues if fallback locales have no change
With this change a call to `Translator::setFallbackLocales()` will not clear the catalogues in case the current fallback locales are already equal to the newly to be set fallback locales.
1 parent e880e53 commit c216bb4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Symfony/Component/Translation/Translator.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ public function getLocale(): string
145145
*/
146146
public function setFallbackLocales(array $locales): void
147147
{
148+
if ($this->getFallbackLocales() === $locales) {
149+
// No change in fallback locales:
150+
// Do not clear catalogues as regeneration of catalogues is computational expensive.
151+
return;
152+
}
153+
148154
// needed as the fallback locales are linked to the already loaded catalogues
149155
$this->catalogues = [];
150156

0 commit comments

Comments
 (0)