From 5912f6d4912ac6641cb6e5751c3974dac2b417a3 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 23 May 2020 10:00:55 -0500 Subject: [PATCH] MovieApi - simplify some long winded comment and subtitle generation. This class seems to very thinly wrap the IMovie api, why not just provide an IMovie? --- .../Api/Classes/MovieApi.cs | 29 ++++--------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/src/BizHawk.Client.Common/Api/Classes/MovieApi.cs b/src/BizHawk.Client.Common/Api/Classes/MovieApi.cs index fb1bb53dfd..bf77fa43c1 100644 --- a/src/BizHawk.Client.Common/Api/Classes/MovieApi.cs +++ b/src/BizHawk.Client.Common/Api/Classes/MovieApi.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.IO; - +using System.Linq; using BizHawk.Emulation.Common; namespace BizHawk.Client.Common @@ -81,29 +81,12 @@ namespace BizHawk.Client.Common return table; } - public List GetComments() - { - var list = new List(Global.MovieSession.Movie.Comments.Count); - if (Global.MovieSession.Movie.NotActive()) - { - return list; - } + public List GetComments() => Global.MovieSession.Movie.Comments.ToList(); - for (var i = 0; i < Global.MovieSession.Movie.Comments.Count; i++) list[i] = Global.MovieSession.Movie.Comments[i]; - return list; - } - - public List GetSubtitles() - { - var list = new List(Global.MovieSession.Movie.Subtitles.Count); - if (Global.MovieSession.Movie.NotActive()) - { - return list; - } - - for (var i = 0; i < Global.MovieSession.Movie.Subtitles.Count; i++) list[i] = Global.MovieSession.Movie.Subtitles[i].ToString(); - return list; - } + public List GetSubtitles() => + Global.MovieSession.Movie.Subtitles + .Select(s => s.ToString()) + .ToList(); public string Filename() => Global.MovieSession.Movie.Filename;