mirror of
https://github.com/reactos/irc.git
synced 2024-11-27 05:40:23 +00:00
[TECHBOT]
-Keep Command instances. This avoids parsing files every time a command is received. svn path=/trunk/irc/; revision=2139
This commit is contained in:
parent
9f7d5915b5
commit
467c521f85
@ -11,6 +11,8 @@ namespace TechBot.Library
|
||||
private string m_CommandName;
|
||||
private string m_CommandHelp;
|
||||
private string m_CommandDesc;
|
||||
private Command m_Instance;
|
||||
object Lock = new object();
|
||||
|
||||
public CommandBuilder(Type commandType)
|
||||
{
|
||||
@ -46,7 +48,17 @@ namespace TechBot.Library
|
||||
|
||||
public Command CreateCommand()
|
||||
{
|
||||
return (Command)Type.Assembly.CreateInstance(Type.FullName, true);
|
||||
// Create command instance and keep it for future uses.
|
||||
lock (Lock)
|
||||
{
|
||||
if (m_Instance != null)
|
||||
return m_Instance;
|
||||
else
|
||||
{
|
||||
m_Instance = (Command)Type.Assembly.CreateInstance(Type.FullName, true);
|
||||
return m_Instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user