Skip to content
Permalink
Browse files

0.72.21 Reduce memory usage

  • Loading branch information...
brakerb committed Aug 11, 2019
1 parent 93c369d commit afb4604c2a92a34d66153cbab15b96c660d2f64d
@@ -165,7 +165,7 @@ public static function beginMap(Map $map)
}
if (!$records && self::$offlineMode) {
$records = $map->dedis->map(function (Dedi $dedi) {
$records = $map->dedis->transform(function (Dedi $dedi) {
$record = collect();
$record->login = $dedi->player->Login;
$record->nickname = $dedi->player->NickName;
@@ -181,7 +181,7 @@ public static function beginMap(Map $map)
//Wipe all dedis for current map
$map->dedis()->where('New', '=', 0)->delete();
$insert = $records->map(function ($record) use ($map) {
$insert = $records->transform(function ($record) use ($map) {
$player = Player::updateOrCreate(['Login' => $record->login], [
'MaxRank' => $record->max_rank,
]);
@@ -215,7 +215,7 @@ private static function cacheDedisJson()
{
self::$dedisJson = self::$dedis->map(function (Dedi $dedi) {
$checkpoints = collect(explode(',', $dedi->Checkpoints));
$checkpoints = $checkpoints->map(function ($time) {
$checkpoints = $checkpoints->transform(function ($time) {
return intval($time);
});
@@ -205,7 +205,7 @@ private static function createJsonFromLocals(Collection $locals)
$playerIds = $locals->pluck('Player');
$players = Player::whereIn('id', $playerIds)->get()->keyBy('id');
return $locals->sortBy('Rank')->map(function (LocalRecord $local) use ($players) {
return $locals->sortBy('Rank')->transform(function (LocalRecord $local) use ($players) {
return [
'r' => $local->Rank,
's' => $local->Score,
@@ -223,7 +223,7 @@ private static function createJsonFromLocals(Collection $locals)
*/
private static function incrementRanksAboveScore(Map $map, int $score)
{
self::$records->where('Score', '>', $score)->map(function (LocalRecord $record) {
self::$records->where('Score', '>', $score)->transform(function (LocalRecord $record) {
$record->Rank++;
return $record;
});
@@ -141,7 +141,7 @@ private static function getMapList(): Collection
//max length ~65762
//length 60088 is ok
return Map::whereEnabled(1)->get()->map(function (Map $map) {
return Map::whereEnabled(1)->get()->transform(function (Map $map) {
if (!$map->id || !$map->gbx->MapUid) {
return null;
}
@@ -159,7 +159,7 @@ private static function getMapList(): Collection
private static function getMapAuthors($authorIds): Collection
{
return Player::whereIn('id', $authorIds)->get()->map(function (Player $player) {
return Player::whereIn('id', $authorIds)->get()->transform(function (Player $player) {
return [
'nick' => $player->NickName,
'login' => $player->Login,
@@ -164,7 +164,7 @@ public static function loadMatchsettings(Player $player, string $matchsettingsFi
public static function getMatchsettings()
{
$files = File::getDirectoryContents(self::$path, '/\.txt$/')->map(function (String $file) {
$files = File::getDirectoryContents(self::$path, '/\.txt$/')->transform(function (String $file) {
return preg_replace('/\.txt$/', '', $file);
});
@@ -44,7 +44,7 @@ public static function showButtons(Player $player)
//Only get buttons the player has access to
return $player->hasAccess($button->access);
})->map(function ($button) {
})->transform(function ($button) {
//convert into maniascript format
return sprintf('["%s", "%s", "%s"]', $button->icon, $button->text, $button->action);
})->implode(',');
@@ -65,7 +65,7 @@ public static function sendUpdatedServerInformations(Player $player = null)
public static function updateServerInformation()
{
self::$servers = self::$servers->map(function ($server) {
self::$servers->transform(function ($server) {
try {
$connection = Connection::factory($server->rpc->host, $server->rpc->port, 100, $server->rpc->login, $server->rpc->pw);
$server->online = true;
@@ -38,7 +38,7 @@ public function __construct(string $stat, string $title, string $prefix = '', st
if ($function) {
//Execute function on values
$this->records = $this->records->map($function);
$this->records = $this->records->transform($function);
}
$this->prefix = $prefix;
@@ -48,7 +48,7 @@ function buildClassMap()
function getNameSpaces(\Illuminate\Support\Collection $classFiles)
{
$classFiles = $classFiles->map(function (\Illuminate\Support\Collection $classFile) {
$classFiles = $classFiles->transform(function (\Illuminate\Support\Collection $classFile) {
$contents = file_get_contents($classFile->file);
if (preg_match('/namespace (.+)?;/i', $contents, $matches)) {

0 comments on commit afb4604

Please sign in to comment.
You can’t perform that action at this time.