From b1c5181b5fcac1945cc77a0136a8fb4341218845 Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 1 Aug 2013 00:37:18 +0000 Subject: [PATCH] REcent Files - roll back last check in I did, oops. --- BizHawk.MultiClient/RecentFiles.cs | 50 ++++++++++++++---------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/BizHawk.MultiClient/RecentFiles.cs b/BizHawk.MultiClient/RecentFiles.cs index bf0623d8c6..3f29d3a8f3 100644 --- a/BizHawk.MultiClient/RecentFiles.cs +++ b/BizHawk.MultiClient/RecentFiles.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; namespace BizHawk.MultiClient @@ -7,57 +6,54 @@ namespace BizHawk.MultiClient public class RecentFiles { private readonly int MAX_RECENT_FILES; //Maximum number of files - private readonly List _recent_list; //List of recent files - - public RecentFiles() - : this(8) { } + private readonly List recentlist; //List of recent files + public RecentFiles() : this(8) { } public RecentFiles(int max) { - _recent_list = new List(); + recentlist = new List(); MAX_RECENT_FILES = max; } public void Clear() { - _recent_list.Clear(); + recentlist.Clear(); } public bool Empty { - get { return _recent_list.Count == 0; } + get { return recentlist.Count == 0; } } public int Count { - get { return _recent_list.Count; } + get { return recentlist.Count; } } public void Add(string newFile) { - foreach (string recent in _recent_list) - { - if (String.Compare(newFile, recent, true) == 0) - { - _recent_list.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place - } - } - - _recent_list.Insert(0, newFile); - if (_recent_list.Count > MAX_RECENT_FILES) + for (int x = 0; x < recentlist.Count; x++) { - _recent_list.Remove(_recent_list[_recent_list.Count - 1]); + if (string.Compare(newFile, recentlist[x]) == 0) + { + recentlist.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place + } + } + recentlist.Insert(0, newFile); + if (recentlist.Count > MAX_RECENT_FILES) + { + recentlist.Remove(recentlist[recentlist.Count - 1]); } } public bool Remove(string newFile) { bool removed = false; - foreach(string recent in _recent_list) + for (int x = 0; x < recentlist.Count; x++) { - if (string.Compare(newFile, recent, true) == 0) + if (string.Compare(newFile, recentlist[x]) == 0) { - _recent_list.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place + recentlist.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place removed = true; } } @@ -67,14 +63,14 @@ namespace BizHawk.MultiClient public List GetRecentListTruncated(int length) { //iterate through list, truncating each item to length, and return the result in a List - return _recent_list.Select(t => t.Substring(0, length)).ToList(); + return recentlist.Select(t => t.Substring(0, length)).ToList(); } public string GetRecentFileByPosition(int position) { - if (_recent_list.Count > 0) + if (recentlist.Count > 0) { - return _recent_list[position]; + return recentlist[position]; } else {