From 182b1d505ae83f330251a2444125c24d7c862260 Mon Sep 17 00:00:00 2001 From: Katsuhisa Yuasa Date: Sat, 21 Jul 2018 04:04:52 +0900 Subject: [PATCH 1/2] =?UTF-8?q?auto=20=E3=82=AD=E3=83=BC=E3=83=AF=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=82=92=E4=BD=BF=E3=81=A3=E3=81=A6=20iterator=20?= =?UTF-8?q?=E5=A4=89=E6=95=B0=E3=81=AE=E5=AE=A3=E8=A8=80=E3=82=92=E7=B0=A1?= =?UTF-8?q?=E6=BD=94=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/CHokanMgr.cpp | 2 +- sakura_core/CProfile.cpp | 36 ++++++++------------------- sakura_core/CSelectLang.cpp | 2 +- sakura_core/charset/CCodePage.cpp | 4 +-- sakura_core/dlg/CDlgPluginOption.cpp | 6 ++--- sakura_core/macro/CCookieManager.cpp | 10 ++++---- sakura_core/macro/CMacroFactory.cpp | 8 +++--- sakura_core/plugin/CJackManager.cpp | 2 +- sakura_core/prop/CPropComMainMenu.cpp | 3 +-- 9 files changed, 27 insertions(+), 46 deletions(-) diff --git a/sakura_core/CHokanMgr.cpp b/sakura_core/CHokanMgr.cpp index 77ad78e0e2..bb99bb9ffa 100644 --- a/sakura_core/CHokanMgr.cpp +++ b/sakura_core/CHokanMgr.cpp @@ -178,7 +178,7 @@ int CHokanMgr::Search( } } - for( CPlug::Array::iterator it = plugs.begin(); it != plugs.end(); ++it ){ + for( auto it = plugs.begin(); it != plugs.end(); ++it ){ //�C���^�t�F�[�X�I�u�W�F�N�g���� CWSHIfObj::List params; std::wstring curWord = pszCurWord; diff --git a/sakura_core/CProfile.cpp b/sakura_core/CProfile.cpp index fee5b6571d..c2acf2b676 100644 --- a/sakura_core/CProfile.cpp +++ b/sakura_core/CProfile.cpp @@ -225,15 +225,10 @@ bool CProfile::WriteProfile( vecLine.push_back( LTEXT(";") + wstring( pszComment ) ); // //->; 2008/5/24 Uchi vecLine.push_back( LTEXT("") ); } - std::vector< Section >::iterator iter; - std::vector< Section >::iterator iterEnd = m_ProfileData.end(); - MAP_STR_STR::iterator mapiter; - MAP_STR_STR::iterator mapiterEnd; - for( iter = m_ProfileData.begin(); iter != iterEnd; iter++ ) { + for(auto iter = m_ProfileData.begin(); iter != m_ProfileData.end(); iter++ ) { //�Z�N�V���������������� vecLine.push_back( LTEXT("[") + iter->strSectionName + LTEXT("]") ); - mapiterEnd = iter->mapEntries.end(); - for( mapiter = iter->mapEntries.begin(); mapiter != mapiterEnd; mapiter++ ) { + for(auto mapiter = iter->mapEntries.cbegin(); mapiter != iter->mapEntries.end(); mapiter++ ) { //�G���g������������ vecLine.push_back( mapiter->first + LTEXT("=") + mapiter->second ); } @@ -329,12 +324,9 @@ bool CProfile::GetProfileDataImp( wstring& strEntryValue //!< [out] �G���g���l ) { - std::vector< Section >::iterator iter; - std::vector< Section >::iterator iterEnd = m_ProfileData.end(); - MAP_STR_STR::iterator mapiter; - for( iter = m_ProfileData.begin(); iter != iterEnd; iter++ ) { + for(auto iter = m_ProfileData.begin(); iter != m_ProfileData.end(); iter++ ) { if( iter->strSectionName == strSectionName ) { - mapiter = iter->mapEntries.find( strEntryKey ); + auto mapiter = iter->mapEntries.find( strEntryKey ); if( iter->mapEntries.end() != mapiter ) { strEntryValue = mapiter->second; return true; @@ -357,14 +349,11 @@ bool CProfile::SetProfileDataImp( const wstring& strEntryValue //!< [in] �G���g���l ) { - std::vector< Section >::iterator iter; - std::vector< Section >::iterator iterEnd = m_ProfileData.end(); - MAP_STR_STR::iterator mapiter; - MAP_STR_STR::iterator mapiterEnd; - for( iter = m_ProfileData.begin(); iter != iterEnd; iter++ ) { + auto iter = m_ProfileData.begin(); + for(; iter != m_ProfileData.end(); iter++ ) { if( iter->strSectionName == strSectionName ) { //�����̃Z�N�V�����̏ꍇ - mapiter = iter->mapEntries.find( strEntryKey ); + auto mapiter = iter->mapEntries.find( strEntryKey ); if( iter->mapEntries.end() != mapiter ) { //�����̃G���g���̏ꍇ�͒l���㏑�� mapiter->second = strEntryValue; @@ -378,7 +367,7 @@ bool CProfile::SetProfileDataImp( } } //�����̃Z�N�V�����ł͂Ȃ��ꍇ�C�Z�N�V�����y�уG���g����lj� - if( iterEnd == iter ) { + if( iter != m_ProfileData.end() ) { Section Buffer; Buffer.strSectionName = strSectionName; Buffer.mapEntries.insert( PAIR_STR_STR( strEntryKey, strEntryValue ) ); @@ -392,16 +381,11 @@ bool CProfile::SetProfileDataImp( void CProfile::DUMP( void ) { #ifdef _DEBUG - std::vector< Section >::iterator iter; - std::vector< Section >::iterator iterEnd = m_ProfileData.end(); // 2006.02.20 ryoji: MAP_STR_STR_ITER�폜���̏C���R��ɂ��R���p�C���G���[�C�� - MAP_STR_STR::iterator mapiter; - MAP_STR_STR::iterator mapiterEnd; MYTRACE( _T("\n\nCProfile::DUMP()======================") ); - for( iter = m_ProfileData.begin(); iter != iterEnd; iter++ ) { + for(auto iter = m_ProfileData.begin(); iter != m_ProfileData.end(); iter++ ) { MYTRACE( _T("\n��strSectionName=%ls"), iter->strSectionName.c_str() ); - mapiterEnd = iter->mapEntries.end(); - for( mapiter = iter->mapEntries.begin(); mapiter != mapiterEnd; mapiter++ ) { + for(auto mapiter = iter->mapEntries.begin(); mapiter != iter->mapEntries.end(); mapiter++ ) { MYTRACE( _T("\"%ls\" = \"%ls\"\n"), mapiter->first.c_str(), mapiter->second.c_str() ); } } diff --git a/sakura_core/CSelectLang.cpp b/sakura_core/CSelectLang.cpp index c0b99f020c..e427a685c6 100644 --- a/sakura_core/CSelectLang.cpp +++ b/sakura_core/CSelectLang.cpp @@ -31,7 +31,7 @@ CSelectLang::PSSelLangInfoList CSelectLang::m_psLangInfoList; */ CSelectLang::~CSelectLang( void ) { - for (PSSelLangInfoList::iterator it = m_psLangInfoList.begin(); it != m_psLangInfoList.end(); it++) { + for (auto it = m_psLangInfoList.begin(); it != m_psLangInfoList.end(); it++) { if( (*it)->hInstance ){ FreeLibrary( (*it)->hInstance ); (*it)->hInstance = NULL; diff --git a/sakura_core/charset/CCodePage.cpp b/sakura_core/charset/CCodePage.cpp index 71abec63fc..6e18bc656f 100644 --- a/sakura_core/charset/CCodePage.cpp +++ b/sakura_core/charset/CCodePage.cpp @@ -438,7 +438,7 @@ CCodePage::CodePageList& CCodePage::GetCodePageList() #endif pfn_GetCPInfoExT_t pfn_GetCPInfoExT = (pfn_GetCPInfoExT_t)::GetProcAddress(hDLLkernel, strFunc_GetCPInfoEx); CPINFOEX cpInfo; - for( CodePageList::iterator it = result.begin(); it != result.end(); ++it ){ + for( auto it = result.begin(); it != result.end(); ++it ){ cpInfo.CodePageName[0] = _T('\0'); if( pfn_GetCPInfoExT && pfn_GetCPInfoExT(it->first, 0, &cpInfo) ){ it->second = to_wchar(cpInfo.CodePageName); @@ -482,7 +482,7 @@ int CCodePage::AddComboCodePages(HWND hwnd, HWND combo, int nSelCode) } Combo_SetItemData( combo, nIdx, CODE_CPOEM ); CCodePage::CodePageList& cpList = CCodePage::GetCodePageList(); - for( CCodePage::CodePageList::iterator it = cpList.begin(); it != cpList.end(); ++it ){ + for( auto it = cpList.begin(); it != cpList.end(); ++it ){ nIdx = Combo_AddString(combo, it->second.c_str()); Combo_SetItemData(combo, nIdx, it->first); if( nSelCode == it->first ){ diff --git a/sakura_core/dlg/CDlgPluginOption.cpp b/sakura_core/dlg/CDlgPluginOption.cpp index 98acaefe7f..f6245b8e95 100644 --- a/sakura_core/dlg/CDlgPluginOption.cpp +++ b/sakura_core/dlg/CDlgPluginOption.cpp @@ -176,7 +176,7 @@ void CDlgPluginOption::SetData( void ) selects = cOpt->GetSelects(); _tcscpy( buf, _T("") ); - for (std::vector::iterator it = selects.begin(); it != selects.end(); it++) { + for (auto it = selects.begin(); it != selects.end(); it++) { SepSelect(*it, &sView, &sTrg); if (sValue == sTrg) { auto_snprintf_s( buf, _countof(buf), _T("%ls"), sView.c_str()); @@ -261,7 +261,7 @@ int CDlgPluginOption::GetData( void ) selects = cOpt->GetSelects(); wstring sWbuf = to_wchar(buf); - for (std::vector::iterator it = selects.begin(); it != selects.end(); it++) { + for (auto it = selects.begin(); it != selects.end(); it++) { SepSelect(*it, &sView, &sTrg); if (sView == sWbuf) { auto_sprintf( buf, _T("%ls"), sTrg.c_str()); @@ -611,7 +611,7 @@ void CDlgPluginOption::SetToEdit( int iLine ) wstring sWbuf = to_wchar(buf); nSelIdx = -1; // �I�� i = 0; - for (std::vector::iterator it = selects.begin(); it != selects.end(); it++) { + for (auto it = selects.begin(); it != selects.end(); it++) { SepSelect(*it, &sView, &sValue); nItemIdx = Combo_AddString( hwndCombo, sView.c_str() ); if (sView == sWbuf) { diff --git a/sakura_core/macro/CCookieManager.cpp b/sakura_core/macro/CCookieManager.cpp index c24ccd2e83..6b797ad934 100644 --- a/sakura_core/macro/CCookieManager.cpp +++ b/sakura_core/macro/CCookieManager.cpp @@ -37,7 +37,7 @@ SysString CCookieManager::GetCookie(LPCWSTR scope, LPCWSTR cookieName) const return SysString(L"", 0); } wstring key = cookieName; - std::map::const_iterator keyVal = cookies->find(key); + const auto& keyVal = cookies->find(key); if( keyVal == cookies->end() ){ return SysString(L"", 0); } @@ -51,7 +51,7 @@ SysString CCookieManager::GetCookieDefault(LPCWSTR scope, LPCWSTR cookieName, LP return SysString(L"", 0); } wstring key = cookieName; - std::map::iterator keyVal = cookies->find(key); + const auto& keyVal = cookies->find(key); if( keyVal == cookies->end() ){ return SysString(defVal, len); } @@ -81,7 +81,7 @@ int CCookieManager::DeleteCookie(LPCWSTR scope, LPCWSTR cookieName) return 2; } wstring key = cookieName; - std::map::iterator keyVal = cookies->find(key); + const auto& keyVal = cookies->find(key); if( keyVal == cookies->end() ){ return 5; } @@ -91,11 +91,11 @@ int CCookieManager::DeleteCookie(LPCWSTR scope, LPCWSTR cookieName) SysString CCookieManager::GetCookieNames(LPCWSTR scope) const { - std::map* cookies = SelectCookieType(scope); + const std::map* cookies = SelectCookieType(scope); if( cookies == NULL ){ return SysString(L"", 0); } - std::map::iterator it = cookies->begin(); + auto& it = cookies->begin(); wstring keyNames; if( it != cookies->end() ){ keyNames += it->first; diff --git a/sakura_core/macro/CMacroFactory.cpp b/sakura_core/macro/CMacroFactory.cpp index 79230fa2af..a7643dcaaa 100644 --- a/sakura_core/macro/CMacroFactory.cpp +++ b/sakura_core/macro/CMacroFactory.cpp @@ -89,14 +89,12 @@ bool CMacroFactory::RegisterCreator( Creator f ) bool CMacroFactory::Unregister( Creator f ) { // Creator Listからの削除 - MacroEngineRep::iterator c_it = m_mMacroCreators.begin(); + auto& c_it = m_mMacroCreators.begin(); while( c_it != m_mMacroCreators.end() ){ if( *c_it == f ){ - MacroEngineRep::iterator tmp_it; - // いきなり削除するとiteratorが無効になるので, // iteratorを1つ進めてから現在位置を削除する. - tmp_it = c_it++; + auto tmp_it = c_it++; m_mMacroCreators.erase( tmp_it ); // 重複登録されている場合を考慮して, // 1つ見つかっても最後までチェックする @@ -123,7 +121,7 @@ CMacroManagerBase* CMacroFactory::Create(const TCHAR* ext) std::tstring key = Ext2Key( ext ); // Creatorを順に試す - for( MacroEngineRep::iterator c_it = m_mMacroCreators.begin(); + for( auto c_it = m_mMacroCreators.begin(); c_it != m_mMacroCreators.end(); ++ c_it ){ CMacroManagerBase* pobj = (*c_it)(key.c_str()); if( pobj != NULL ){ diff --git a/sakura_core/plugin/CJackManager.cpp b/sakura_core/plugin/CJackManager.cpp index 6cfce55ccc..37824dab34 100644 --- a/sakura_core/plugin/CJackManager.cpp +++ b/sakura_core/plugin/CJackManager.cpp @@ -183,7 +183,7 @@ bool CJackManager::GetUsablePlug( CPlug::Array* plugs //!< [out] ���p�”\�v���O�̃��X�g ) { - for( CPlug::Array::iterator it = m_Jacks[jack].plugs.begin(); it != m_Jacks[jack].plugs.end(); it++ ){ + for( auto it = m_Jacks[jack].plugs.begin(); it != m_Jacks[jack].plugs.end(); it++ ){ if( plugId == 0 || plugId == (*it)->GetFunctionCode() ){ plugs->push_back( *it ); } diff --git a/sakura_core/prop/CPropComMainMenu.cpp b/sakura_core/prop/CPropComMainMenu.cpp index bbdcdefe48..f214bc6593 100644 --- a/sakura_core/prop/CPropComMainMenu.cpp +++ b/sakura_core/prop/CPropComMainMenu.cpp @@ -1251,7 +1251,6 @@ bool CPropMainMenu::Check_MainMenu_Sub( TV_ITEM tvi; // �擾�p SMainMenuWork* pFuncWk; // �@�\(work) std::map< WCHAR, HTREEITEM > mKey; // �d���G���[���o�p - std::map< WCHAR, HTREEITEM >::iterator itKey; // ���� if (nLevel == 0) { bOptionOk = false; @@ -1309,7 +1308,7 @@ bool CPropMainMenu::Check_MainMenu_Sub( } } else { - itKey = mKey.find( pFuncWk->m_sKey[0] ); + auto itKey = mKey.find( pFuncWk->m_sKey[0] ); if (itKey == mKey.end()) { mKey[pFuncWk->m_sKey[0]] = s; From 5ff59168e482eed3989426eff28f47409dbb457d Mon Sep 17 00:00:00 2001 From: Katsuhisa Yuasa Date: Sat, 21 Jul 2018 13:30:30 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E6=8C=87=E6=91=98=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/macro/CCookieManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sakura_core/macro/CCookieManager.cpp b/sakura_core/macro/CCookieManager.cpp index 6b797ad934..bf2c9fcc71 100644 --- a/sakura_core/macro/CCookieManager.cpp +++ b/sakura_core/macro/CCookieManager.cpp @@ -37,7 +37,7 @@ SysString CCookieManager::GetCookie(LPCWSTR scope, LPCWSTR cookieName) const return SysString(L"", 0); } wstring key = cookieName; - const auto& keyVal = cookies->find(key); + auto keyVal = cookies->find(key); if( keyVal == cookies->end() ){ return SysString(L"", 0); } @@ -95,7 +95,7 @@ SysString CCookieManager::GetCookieNames(LPCWSTR scope) const if( cookies == NULL ){ return SysString(L"", 0); } - auto& it = cookies->begin(); + auto it = cookies->begin(); wstring keyNames; if( it != cookies->end() ){ keyNames += it->first;