Minor cleanup

This commit is contained in:
Wojtek Figat
2024-10-17 23:43:07 +02:00
parent c94052513e
commit 91d86552cd
2 changed files with 10 additions and 9 deletions

View File

@@ -99,10 +99,11 @@ namespace
bool Inited = false; bool Inited = false;
Array<CommandData> Commands; Array<CommandData> Commands;
void OnBinaryModuleLoaded(BinaryModule* module) void FindDebugCommands(BinaryModule* module)
{ {
if (module == GetBinaryModuleCorlib()) if (module == GetBinaryModuleCorlib())
return; return;
PROFILE_CPU();
#if USE_CSHARP #if USE_CSHARP
if (auto* managedModule = dynamic_cast<ManagedBinaryModule*>(module)) if (auto* managedModule = dynamic_cast<ManagedBinaryModule*>(module))
@@ -200,9 +201,9 @@ namespace
const auto& modules = BinaryModule::GetModules(); const auto& modules = BinaryModule::GetModules();
for (BinaryModule* module : modules) for (BinaryModule* module : modules)
{ {
OnBinaryModuleLoaded(module); FindDebugCommands(module);
} }
Scripting::BinaryModuleLoaded.Bind(&OnBinaryModuleLoaded); Scripting::BinaryModuleLoaded.Bind(&FindDebugCommands);
Scripting::ScriptsReloading.Bind(&OnScriptsReloading); Scripting::ScriptsReloading.Bind(&OnScriptsReloading);
} }
} }
@@ -219,7 +220,7 @@ public:
{ {
// Cleanup // Cleanup
ScopeLock lock(Locker); ScopeLock lock(Locker);
Scripting::BinaryModuleLoaded.Unbind(&OnBinaryModuleLoaded); Scripting::BinaryModuleLoaded.Unbind(&FindDebugCommands);
Scripting::ScriptsReloading.Unbind(&OnScriptsReloading); Scripting::ScriptsReloading.Unbind(&OnScriptsReloading);
Commands.Clear(); Commands.Clear();
Inited = true; Inited = true;
@@ -252,12 +253,12 @@ void DebugCommands::Execute(StringView command)
InitCommands(); InitCommands();
// Find command to run // Find command to run
for (const CommandData& command : Commands) for (const CommandData& cmd : Commands)
{ {
if (name.Length() == command.Name.Length() && if (name.Length() == cmd.Name.Length() &&
StringUtils::CompareIgnoreCase(name.Get(), command.Name.Get(), name.Length()) == 0) StringUtils::CompareIgnoreCase(name.Get(), cmd.Name.Get(), name.Length()) == 0)
{ {
command.Invoke(args); cmd.Invoke(args);
return; return;
} }
} }

View File

@@ -13,7 +13,7 @@ API_CLASS(static) class FLAXENGINE_API DebugCommands
public: public:
/// <summary> /// <summary>
/// Executees the command. /// Executes the command.
/// </summary> /// </summary>
/// <param name="command">The command line (optionally with arguments).</param> /// <param name="command">The command line (optionally with arguments).</param>
API_FUNCTION() static void Execute(StringView command); API_FUNCTION() static void Execute(StringView command);