From c27ae20b771019be802c2554896c3b43f23c93d7 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Fri, 27 Sep 2013 17:14:28 +0200 Subject: [PATCH] Change min/max in LineBase to use simpler LINQ query --- VocaluxeLib/Songs/CLineBase.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/VocaluxeLib/Songs/CLineBase.cs b/VocaluxeLib/Songs/CLineBase.cs index 0a819509..41d88909 100644 --- a/VocaluxeLib/Songs/CLineBase.cs +++ b/VocaluxeLib/Songs/CLineBase.cs @@ -63,15 +63,10 @@ namespace VocaluxeLib.Songs { get { - int min = int.MaxValue; - int max = int.MinValue; - foreach (T note in _Notes) - { - if (note.Tone < min) - min = note.Tone; - if (note.Tone > max) - max = note.Tone; - } + if (_Notes.Count == 0) + return 0; + int min = _Notes.Max(note => note.Tone); + int max = _Notes.Min(note => note.Tone); return min - (max - min) / 4; }