[MSPAINT] Simplify tool creation (#5876)

Reduce code and binary size. This will reduce 512 bytes in binary.
- Don't use cache for tool creation.
CORE-19094
This commit is contained in:
Katayama Hirofumi MZ 2023-11-03 16:49:13 +09:00 committed by GitHub
parent 37f56d2448
commit a6418c848c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 8 deletions

View file

@ -22,22 +22,20 @@ ToolsModel::ToolsModel()
m_rubberRadius = 4;
m_transpBg = FALSE;
m_zoom = 1000;
ZeroMemory(&m_tools, sizeof(m_tools));
m_pToolObject = GetOrCreateTool(m_activeTool);
}
ToolsModel::~ToolsModel()
{
for (size_t i = 0; i < _countof(m_tools); ++i)
delete m_tools[i];
delete m_pToolObject;
m_pToolObject = NULL;
}
ToolBase *ToolsModel::GetOrCreateTool(TOOLTYPE nTool)
{
if (!m_tools[nTool])
m_tools[nTool] = ToolBase::createToolObject(nTool);
return m_tools[nTool];
delete m_pToolObject;
m_pToolObject = ToolBase::createToolObject(nTool);
return m_pToolObject;
}
BOOL ToolsModel::IsSelection() const

View file

@ -84,7 +84,6 @@ private:
int m_rubberRadius;
BOOL m_transpBg;
int m_zoom;
ToolBase* m_tools[TOOL_MAX + 1];
ToolBase *m_pToolObject;
ToolBase *GetOrCreateTool(TOOLTYPE nTool);