Skip to content

Commit 03adbe5

Browse files
committed
Optimize memory usage in listFromGame function
1 parent 8936f9b commit 03adbe5

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/Storage/Driver/MySQL.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public static function listFromGame(int $time = 0)
335335
//return $sth->fetchAll(PDO::FETCH_ASSOC);
336336

337337
$results = [];
338-
foreach ($sth->fetchAll(PDO::FETCH_ASSOC) as $entry) {
338+
while ($entry = $sth->fetch(PDO::FETCH_ASSOC)) {
339339
$json = json_decode($entry['data'], true);
340340
$data_stripped = json_encode(['game_code' => $json['game_code'] ?? null]);
341341

src/Storage/Driver/PostgreSQL.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public static function listFromGame(int $time = 0)
327327
//return $sth->fetchAll(PDO::FETCH_ASSOC);
328328

329329
$results = [];
330-
foreach ($sth->fetchAll(PDO::FETCH_ASSOC) as $entry) {
330+
while ($entry = $sth->fetch(PDO::FETCH_ASSOC)) {
331331
$json = json_decode($entry['data'], true);
332332
$data_stripped = json_encode(['game_code' => $json['game_code'] ?? null]);
333333

0 commit comments

Comments
 (0)