From: <man...@us...> - 2015-06-07 18:06:46
|
Revision: 5265 http://sourceforge.net/p/modplug/code/5265 Author: manxorist Date: 2015-06-07 18:06:40 +0000 (Sun, 07 Jun 2015) Log Message: ----------- [Ref] Settings: Use explicitely named reference accessor functions. [Ref] Advanced settings: Reduce object and string copying some more. Modified Paths: -------------- trunk/OpenMPT/mptrack/AdvancedConfigDlg.cpp trunk/OpenMPT/mptrack/Settings.h Modified: trunk/OpenMPT/mptrack/AdvancedConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/AdvancedConfigDlg.cpp 2015-06-07 16:54:20 UTC (rev 5264) +++ trunk/OpenMPT/mptrack/AdvancedConfigDlg.cpp 2015-06-07 18:06:40 UTC (rev 5265) @@ -104,7 +104,6 @@ { m_List.SetRedraw(FALSE); m_List.DeleteAllItems(); - const bool useGroups = m_ListGrouped; m_List.SetItemCount(theApp.GetSettings().size()); m_IndexToPath.clear(); @@ -118,63 +117,96 @@ for(SettingsContainer::SettingsMap::const_iterator it = theApp.GetSettings().begin(); it != theApp.GetSettings().end(); ++it) { const SettingPath &path = it->first; - const SettingValue &value = it->second; + const SettingState &state = it->second; + const mpt::ustring §ion = path.GetRefSection(); + const mpt::ustring &key = path.GetRefKey(); + const SettingValue &value = state.GetRefValue(); + const SettingValue &defaultValue = state.GetRefDefault(); - int groupID = 0; - const mpt::ustring §ion = path.GetSection(); - UNORDERED_MAP<mpt::ustring, int>::const_iterator gi = m_Groups.find(section); - if(gi == m_Groups.end() && useGroups) - { - LVGROUP group; -#if _WIN32_WINNT >= 0x0600 - group.cbSize = LVGROUP_V5_SIZE; -#else - group.cbSize = sizeof(group); -#endif - group.mask = LVGF_HEADER | LVGF_GROUPID; - group.pszHeader = const_cast<wchar_t *>(section.c_str()); - group.cchHeader = 0; - group.pszFooter = nullptr; - group.cchFooter = 0; - group.iGroupId = groupID = numGroups++; - group.stateMask = LVGS_COLLAPSIBLE; - group.state = LVGS_COLLAPSIBLE; - group.uAlign = LVGA_HEADER_LEFT; - ListView_InsertGroup(m_List.m_hWnd, -1, &group); - m_Groups.insert(std::make_pair(section, groupID)); - } else - { - groupID = gi->second; - } - bool addString = true; if(!findStr.IsEmpty()) { CString str = mpt::ToCString(path.FormatAsString() + MPT_USTRING(" = ") + value.FormatValueAsString()); - addString = str.MakeLower().Find(findStr) >= 0; + addString = (str.MakeLower().Find(findStr) >= 0); } - if(addString) + + if(m_ListGrouped) { - const mpt::ustring str = useGroups ? it->first.GetKey() : it->first.FormatAsString(); - LVITEMW lvi; - lvi.mask = LVIF_TEXT | LVIF_PARAM | (useGroups ? LVIF_GROUPID : 0); - lvi.iItem = i++; - lvi.iSubItem = 0; - lvi.state = 0; - lvi.stateMask = 0; - lvi.pszText = const_cast<wchar_t *>(str.c_str()); - lvi.cchTextMax = 0; - lvi.iImage = 0; - lvi.lParam = m_IndexToPath.size(); - lvi.iIndent = 0; - lvi.iGroupId = (useGroups ? groupID : 0); - int index = static_cast<int>(m_List.SendMessage(LVM_INSERTITEMW, 0, (LPARAM)(&lvi))); - m_List.SetItemText(index, 1, value.FormatTypeAsString().c_str()); - m_List.SetItemText(index, 2, value.FormatValueAsString().c_str()); - m_List.SetItemText(index, 3, it->second.GetDefault().FormatValueAsString().c_str()); - m_IndexToPath.push_back(it->first); + int groupID = 0; + UNORDERED_MAP<mpt::ustring, int>::const_iterator gi = m_Groups.find(section); + if(gi == m_Groups.end()) + { + LVGROUP group; + #if _WIN32_WINNT >= 0x0600 + group.cbSize = LVGROUP_V5_SIZE; + #else + group.cbSize = sizeof(group); + #endif + group.mask = LVGF_HEADER | LVGF_GROUPID; + group.pszHeader = const_cast<wchar_t *>(section.c_str()); + group.cchHeader = 0; + group.pszFooter = nullptr; + group.cchFooter = 0; + group.iGroupId = groupID = numGroups++; + group.stateMask = LVGS_COLLAPSIBLE; + group.state = LVGS_COLLAPSIBLE; + group.uAlign = LVGA_HEADER_LEFT; + ListView_InsertGroup(m_List.m_hWnd, -1, &group); + m_Groups.insert(std::make_pair(section, groupID)); + } else + { + groupID = gi->second; + } + + if(addString) + { + LVITEMW lvi; + lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_GROUPID; + lvi.iItem = i++; + lvi.iSubItem = 0; + lvi.state = 0; + lvi.stateMask = 0; + lvi.pszText = const_cast<wchar_t *>(key.c_str()); + lvi.cchTextMax = 0; + lvi.iImage = 0; + lvi.lParam = m_IndexToPath.size(); + lvi.iIndent = 0; + lvi.iGroupId = groupID; + int index = static_cast<int>(m_List.SendMessage(LVM_INSERTITEMW, 0, (LPARAM)(&lvi))); + m_List.SetItemText(index, 1, value.FormatTypeAsString().c_str()); + m_List.SetItemText(index, 2, value.FormatValueAsString().c_str()); + m_List.SetItemText(index, 3, defaultValue.FormatValueAsString().c_str()); + m_IndexToPath.push_back(path); + } + + } else + { + + if(addString) + { + const mpt::ustring sectionAndKey = path.FormatAsString(); + LVITEMW lvi; + lvi.mask = LVIF_TEXT | LVIF_PARAM; + lvi.iItem = i++; + lvi.iSubItem = 0; + lvi.state = 0; + lvi.stateMask = 0; + lvi.pszText = const_cast<wchar_t *>(sectionAndKey.c_str()); + lvi.cchTextMax = 0; + lvi.iImage = 0; + lvi.lParam = m_IndexToPath.size(); + lvi.iIndent = 0; + lvi.iGroupId = 0; + int index = static_cast<int>(m_List.SendMessage(LVM_INSERTITEMW, 0, (LPARAM)(&lvi))); + m_List.SetItemText(index, 1, value.FormatTypeAsString().c_str()); + m_List.SetItemText(index, 2, value.FormatValueAsString().c_str()); + m_List.SetItemText(index, 3, defaultValue.FormatValueAsString().c_str()); + m_IndexToPath.push_back(path); + } + } + } m_List.SetItemCount(i); Modified: trunk/OpenMPT/mptrack/Settings.h =================================================================== --- trunk/OpenMPT/mptrack/Settings.h 2015-06-07 16:54:20 UTC (rev 5264) +++ trunk/OpenMPT/mptrack/Settings.h 2015-06-07 18:06:40 UTC (rev 5265) @@ -395,10 +395,14 @@ return *this; } #if defined(MPT_SETTINGS_CACHE_STORE_DEFAULTS) - const SettingValue &GetDefault() const + SettingValue GetDefault() const { return defaultValue; } + const SettingValue &GetRefDefault() const + { + return defaultValue; + } #endif // MPT_SETTINGS_CACHE_STORE_DEFAULTS bool IsDirty() const { @@ -408,6 +412,14 @@ { dirty = false; } + SettingValue GetValue() const + { + return value; + } + const SettingValue &GetRefValue() const + { + return value; + } operator SettingValue () const { return value; @@ -435,14 +447,22 @@ { return; } - const mpt::ustring &GetSection() const + mpt::ustring GetSection() const { return section; } - const mpt::ustring &GetKey() const + mpt::ustring GetKey() const { return key; } + const mpt::ustring &GetRefSection() const + { + return section; + } + const mpt::ustring &GetRefKey() const + { + return key; + } int compare(const SettingPath &other) const { int cmp_section = section.compare(other.section); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |