From ea48d6a88a7e1caaecbdfa684b9e8c8f2b093f86 Mon Sep 17 00:00:00 2001 From: ekrctb Date: Sat, 26 Jan 2019 16:16:49 +0900 Subject: [PATCH] reduce code duplication / allocations --- .../Objects/JuiceStream.cs | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs b/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs index 8cbd824805..88b96aa0c4 100644 --- a/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs +++ b/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs @@ -55,6 +55,13 @@ namespace osu.Game.Rulesets.Catch.Objects var minDistanceFromEnd = Velocity * 0.01; + var tickSamples = Samples.Select(s => new SampleInfo + { + Bank = s.Bank, + Name = @"slidertick", + Volume = s.Volume + }).ToList(); + AddNested(new Fruit { Samples = Samples, @@ -107,12 +114,7 @@ namespace osu.Game.Rulesets.Catch.Objects { StartTime = t, X = X + Path.PositionAt(progress).X / CatchPlayfield.BASE_WIDTH, - Samples = new List(Samples.Select(s => new SampleInfo - { - Bank = s.Bank, - Name = @"slidertick", - Volume = s.Volume - })) + Samples = tickSamples }); } @@ -125,12 +127,7 @@ namespace osu.Game.Rulesets.Catch.Objects { StartTime = time, X = X + Path.PositionAt(distanceProgress).X / CatchPlayfield.BASE_WIDTH, - Samples = new List(Samples.Select(s => new SampleInfo - { - Bank = s.Bank, - Name = @"slidertick", - Volume = s.Volume - })) + Samples = tickSamples }); }