bug #14236 [Translation][Profiler] reduce memory usage for collected messages. (aitboudad)
This PR was merged into the 2.7 branch.
Discussion
----------
[Translation][Profiler] reduce memory usage for collected messages.
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Fixed tickets | ~
| Tests pass? | yes
| License | MIT
for 1000 translated messages:
![selection_025](https://cloud.githubusercontent.com/assets/1753742/7006976/7df77336-dc7d-11e4-8e35-78d3bc42d324.png)
Commits
-------
21526ea
[Translation][Profiler] reduce memory usage for collected messages.
This commit is contained in:
commit
874346ffeb
@ -95,21 +95,22 @@ class TranslationDataCollector extends DataCollector implements LateDataCollecto
|
|||||||
|
|
||||||
private function sanitizeCollectedMessages($messages)
|
private function sanitizeCollectedMessages($messages)
|
||||||
{
|
{
|
||||||
|
$result = array();
|
||||||
foreach ($messages as $key => $message) {
|
foreach ($messages as $key => $message) {
|
||||||
$messages[$key]['translation'] = $this->sanitizeString($message['translation']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_reduce($messages, function ($result, $message) {
|
|
||||||
$messageId = $message['locale'].$message['domain'].$message['id'];
|
$messageId = $message['locale'].$message['domain'].$message['id'];
|
||||||
|
|
||||||
if (!isset($result[$messageId])) {
|
if (!isset($result[$messageId])) {
|
||||||
$message['count'] = 1;
|
$message['count'] = 1;
|
||||||
|
$messages[$key]['translation'] = $this->sanitizeString($message['translation']);
|
||||||
$result[$messageId] = $message;
|
$result[$messageId] = $message;
|
||||||
} else {
|
} else {
|
||||||
$result[$messageId]['count']++;
|
$result[$messageId]['count']++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
unset($messages[$key]);
|
||||||
}, array());
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function computeCount($messages)
|
private function computeCount($messages)
|
||||||
|
Reference in New Issue
Block a user