Skip to content

Commit 048fc45

Browse files
committed
bug #3219 [Translator] Early exit parameters extraction from Intl messages, if no { is found (Kocal)
This PR was merged into the 2.x branch. Discussion ---------- [Translator] Early exit parameters extraction from Intl messages, if no `{` is found | Q | A | -------------- | --- | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- if yes, also update UPGRADE-*.md and src/**/CHANGELOG.md --> | Documentation? | no <!-- required for new features, or documentation updates --> | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT Following #3218 On an app with ~3320 keys, ~2870 of them didn't use the ICU syntax. Early exiting when no `{` reduced the cache-clear time by ~60%: [![](https://github.com/user-attachments/assets/481076d8-1d5c-4b98-b454-e936d16b3ca9)](https://blackfire.io/profiles/compare/209538ae-26bf-40bf-a3f4-5a51d91a4fe7/graph) Commits ------- c8a303c [Translator] Early exit parameters extraction from Intl messages, if no `{` is found
2 parents aaa5c9d + c8a303c commit 048fc45

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Translator/src/MessageParameters/Extractor/IntlMessageParametersExtractor.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ final class IntlMessageParametersExtractor implements ExtractorInterface
2323
{
2424
public function extract(string $message): array
2525
{
26+
// Early return if there is no parameter-like pattern in the message
27+
if (!str_contains($message, '{')) {
28+
return [];
29+
}
30+
2631
$parameters = [];
2732

2833
$intlMessageParser = new IntlMessageParser($message);

0 commit comments

Comments
 (0)