mirror of https://github.com/ppy/osu
Avoid using parameterless constructors in migration code
Minor performance improvement (less garbage).
This commit is contained in:
parent
42736c9995
commit
fd5198d667
|
@ -122,7 +122,10 @@ private void migrateBeatmaps(OsuDbContext ef)
|
|||
|
||||
foreach (var beatmap in beatmapSet.Beatmaps)
|
||||
{
|
||||
var realmBeatmap = new BeatmapInfo
|
||||
var ruleset = realm.Find<RulesetInfo>(beatmap.RulesetInfo.ShortName);
|
||||
var metadata = getBestMetadata(beatmap.Metadata, beatmapSet.Metadata);
|
||||
|
||||
var realmBeatmap = new BeatmapInfo(ruleset, new BeatmapDifficulty(beatmap.BaseDifficulty), metadata)
|
||||
{
|
||||
DifficultyName = beatmap.DifficultyName,
|
||||
Status = beatmap.Status,
|
||||
|
@ -148,9 +151,6 @@ private void migrateBeatmaps(OsuDbContext ef)
|
|||
CountdownOffset = beatmap.CountdownOffset,
|
||||
MaxCombo = beatmap.MaxCombo,
|
||||
Bookmarks = beatmap.Bookmarks,
|
||||
Ruleset = realm.Find<RulesetInfo>(beatmap.RulesetInfo.ShortName),
|
||||
Difficulty = new BeatmapDifficulty(beatmap.BaseDifficulty),
|
||||
Metadata = getBestMetadata(beatmap.Metadata, beatmapSet.Metadata),
|
||||
BeatmapSet = realmBeatmapSet,
|
||||
};
|
||||
|
||||
|
@ -180,7 +180,7 @@ private BeatmapMetadata getBestMetadata(EFBeatmapMetadata? beatmapMetadata, EFBe
|
|||
TitleUnicode = metadata.TitleUnicode,
|
||||
Artist = metadata.Artist,
|
||||
ArtistUnicode = metadata.ArtistUnicode,
|
||||
Author = new RealmUser
|
||||
Author =
|
||||
{
|
||||
OnlineID = metadata.Author.Id,
|
||||
Username = metadata.Author.Username,
|
||||
|
@ -248,7 +248,15 @@ private void migrateScores(OsuDbContext db)
|
|||
Logger.Log($"Migrated {written}/{count} scores...", LoggingTarget.Database);
|
||||
}
|
||||
|
||||
var realmScore = new ScoreInfo
|
||||
var beatmap = realm.All<BeatmapInfo>().First(b => b.Hash == score.BeatmapInfo.Hash);
|
||||
var ruleset = realm.Find<RulesetInfo>(score.Ruleset.ShortName);
|
||||
var user = new RealmUser
|
||||
{
|
||||
OnlineID = score.User.OnlineID,
|
||||
Username = score.User.Username
|
||||
};
|
||||
|
||||
var realmScore = new ScoreInfo(beatmap, ruleset, user)
|
||||
{
|
||||
Hash = score.Hash,
|
||||
DeletePending = score.DeletePending,
|
||||
|
@ -262,8 +270,8 @@ private void migrateScores(OsuDbContext db)
|
|||
HasReplay = ((IScoreInfo)score).HasReplay,
|
||||
Date = score.Date,
|
||||
PP = score.PP,
|
||||
BeatmapInfo = realm.All<BeatmapInfo>().First(b => b.Hash == score.BeatmapInfo.Hash),
|
||||
Ruleset = realm.Find<RulesetInfo>(score.Ruleset.ShortName),
|
||||
BeatmapInfo = beatmap,
|
||||
Ruleset = ruleset,
|
||||
Rank = score.Rank,
|
||||
HitEvents = score.HitEvents,
|
||||
Passed = score.Passed,
|
||||
|
|
Loading…
Reference in New Issue