Skip to content

Commit f3799fb

Browse files
committed
Clean up hack in MemoryLuaLibrary.GetMemoryDomainList
1 parent 6abed2b commit f3799fb

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/BizHawk.Client.Common/lua/CommonLibs/MemoryLuaLibrary.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Collections.Generic;
21
using System.ComponentModel;
32
using System.Linq;
43

@@ -18,7 +17,7 @@ public MemoryLuaLibrary(ILuaLibraries luaLibsImpl, ApiContainer apiContainer, Ac
1817
[LuaMethodExample("local nlmemget = memory.getmemorydomainlist();")]
1918
[LuaMethod("getmemorydomainlist", "Returns a string of the memory domains for the loaded platform core. List will be a single string delimited by line feeds")]
2019
public LuaTable GetMemoryDomainList()
21-
=> _th.ListToTable((List<string>) APIs.Memory.GetMemoryDomainList(), indexFrom: 0); //HACK cast will succeed as long as impl. returns .Select<T, string>().ToList() as IROC<string>
20+
=> _th.EnumerateToLuaTable(APIs.Memory.GetMemoryDomainList(), indexFrom: 0);
2221

2322
[LuaMethodExample("local uimemget = memory.getmemorydomainsize( mainmemory.getname( ) );")]
2423
[LuaMethod("getmemorydomainsize", "Returns the number of bytes of the specified memory domain. If no domain is specified, or the specified domain doesn't exist, returns the current domain size")]

src/BizHawk.Client.Common/lua/LuaHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ namespace BizHawk.Client.Common
88
public static class LuaExtensions
99
{
1010
public static LuaTable EnumerateToLuaTable<T>(this NLuaTableHelper tableHelper, IEnumerable<T> list, int indexFrom = 1)
11-
=> tableHelper.ListToTable(list.ToList(), indexFrom);
11+
=> tableHelper.ListToTable(list as IReadOnlyList<T> ?? list.ToList(), indexFrom);
1212
}
1313
}

0 commit comments

Comments
 (0)