Skip to content

Commit 89e94be

Browse files
committed
Memoise a value during Lua lib function enumeration
1 parent ea810cb commit 89e94be

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/BizHawk.Client.EmuHawk/tools/Lua/LuaLibraries.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,18 @@ public LuaLibraries(
3737

3838
void EnumerateLuaFunctions(string name, Type type, LuaLibraryBase instance)
3939
{
40+
var libraryDesc = type.GetCustomAttributes(typeof(DescriptionAttribute), false).Cast<DescriptionAttribute>()
41+
.Select(static descAttr => descAttr.Description)
42+
.FirstOrDefault() ?? string.Empty;
4043
if (instance != null) _lua.NewTable(name);
4144
foreach (var method in type.GetMethods())
4245
{
4346
var foundAttrs = method.GetCustomAttributes(typeof(LuaMethodAttribute), false);
4447
if (foundAttrs.Length == 0) continue;
4548
if (instance != null) _lua.RegisterFunction($"{name}.{((LuaMethodAttribute)foundAttrs[0]).Name}", instance, method);
4649
LibraryFunction libFunc = new(
47-
name,
48-
type.GetCustomAttributes(typeof(DescriptionAttribute), false).Cast<DescriptionAttribute>()
49-
.Select(descAttr => descAttr.Description).FirstOrDefault() ?? string.Empty,
50+
library: name,
51+
libraryDescription: libraryDesc,
5052
method,
5153
suggestInREPL: false
5254
);

0 commit comments

Comments
 (0)