From 50e9e87e446f6c17a4021e32c9ff6a9f5e8575ae Mon Sep 17 00:00:00 2001 From: Rajendra Singh Date: Fri, 1 Mar 2019 19:12:26 +0530 Subject: [PATCH] Use the reference parameter instead of copy parameter and some clean up Close #5360 --- PowerEditor/src/MISC/Common/Common.cpp | 2 +- PowerEditor/src/MISC/Common/verifySignedfile.cpp | 4 ++-- PowerEditor/src/MISC/Common/verifySignedfile.h | 4 ++-- PowerEditor/src/Parameters.cpp | 4 +++- PowerEditor/src/ScitillaComponent/ScintillaCtrls.h | 4 ++-- PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h | 6 ------ PowerEditor/src/WinControls/shortcut/shortcut.h | 4 ++-- 7 files changed, 12 insertions(+), 16 deletions(-) diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 68603951..851e0948 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -1155,7 +1155,7 @@ bool isCertificateValidated(const generic_string & fullFilePath, const generic_s isOK = true; } - catch (generic_string s) + catch (const generic_string& s) { // display error message MessageBox(NULL, s.c_str(), TEXT("Certificate checking"), MB_OK); diff --git a/PowerEditor/src/MISC/Common/verifySignedfile.cpp b/PowerEditor/src/MISC/Common/verifySignedfile.cpp index aac1a9da..927462e1 100644 --- a/PowerEditor/src/MISC/Common/verifySignedfile.cpp +++ b/PowerEditor/src/MISC/Common/verifySignedfile.cpp @@ -57,7 +57,7 @@ SecurityGard::SecurityGard() _pluginListSha256.push_back(TEXT("3ecd7f9c56bcd659a4126c659eb69b354789c78574a82390749ac751ae539bc6")); // v1.0.7 64 bit (unsigned) } -bool SecurityGard::checkModule(std::wstring filePath, NppModule module2check) +bool SecurityGard::checkModule(const std::wstring& filePath, NppModule module2check) { if (_securityMode == sm_certif) return verifySignedLibrary(filePath, module2check); @@ -67,7 +67,7 @@ bool SecurityGard::checkModule(std::wstring filePath, NppModule module2check) return false; } -bool SecurityGard::checkSha256(std::wstring filePath, NppModule module2check) +bool SecurityGard::checkSha256(const std::wstring& filePath, NppModule module2check) { std::string content = getFileContent(filePath.c_str()); uint8_t sha2hash[32]; diff --git a/PowerEditor/src/MISC/Common/verifySignedfile.h b/PowerEditor/src/MISC/Common/verifySignedfile.h index 5f1b9c8e..45994901 100644 --- a/PowerEditor/src/MISC/Common/verifySignedfile.h +++ b/PowerEditor/src/MISC/Common/verifySignedfile.h @@ -66,7 +66,7 @@ class SecurityGard final { public: SecurityGard(); - bool checkModule(std::wstring filePath, NppModule module2check); + bool checkModule(const std::wstring& filePath, NppModule module2check); private: // SHA256 @@ -75,7 +75,7 @@ private: std::vector _gupSha256; std::vector _pluginListSha256; - bool checkSha256(std::wstring filePath, NppModule module2check); + bool checkSha256(const std::wstring& filePath, NppModule module2check); // Code signing certificate std::wstring _signer_display_name = TEXT("Notepad++"); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 3660bf67..9ce6bd28 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -2652,7 +2652,9 @@ std::pair NppParameters::feedUserLang(TiXmlNode *n _userLangArray[_nbUserLang - 1]->_styleArray.addStyler(i, globalMappper().styleNameMapper[i].c_str()); } - } catch (std::exception e) { + } + catch (const std::exception& /*e*/) + { delete _userLangArray[--_nbUserLang]; } } diff --git a/PowerEditor/src/ScitillaComponent/ScintillaCtrls.h b/PowerEditor/src/ScitillaComponent/ScintillaCtrls.h index 81b4a61e..0cc6351b 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaCtrls.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaCtrls.h @@ -48,8 +48,8 @@ public : private: std::vector _scintVector; - HINSTANCE _hInst; - HWND _hParent; + HINSTANCE _hInst = nullptr; + HWND _hParent = nullptr; int getIndexFrom(HWND handle2Find); }; diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h index 0c457a3a..108cb9b6 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h @@ -60,12 +60,6 @@ class WindowsDlg : public SizeableDlg { typedef SizeableDlg MyBaseClass; - class CachedValue - { - generic_string fullname; - int index; - }; - public : WindowsDlg(); int doDialog(); diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.h b/PowerEditor/src/WinControls/shortcut/shortcut.h index 68535a7d..065b84e0 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.h +++ b/PowerEditor/src/WinControls/shortcut/shortcut.h @@ -321,7 +321,7 @@ private: class UserCommand : public CommandShortcut { friend class NppParameters; public: - UserCommand(Shortcut sc, const TCHAR *cmd, int id) : CommandShortcut(sc, id), _cmd(cmd) {_canModifyName = true;}; + UserCommand(const Shortcut& sc, const TCHAR *cmd, int id) : CommandShortcut(sc, id), _cmd(cmd) {_canModifyName = true;}; const TCHAR* getCmd() const {return _cmd.c_str();}; private: generic_string _cmd; @@ -330,7 +330,7 @@ private: class PluginCmdShortcut : public CommandShortcut { //friend class NppParameters; public: - PluginCmdShortcut(Shortcut sc, int id, const TCHAR *moduleName, unsigned short internalID) :\ + PluginCmdShortcut(const Shortcut& sc, int id, const TCHAR *moduleName, unsigned short internalID) :\ CommandShortcut(sc, id), _id(id), _moduleName(moduleName), _internalID(internalID) {}; bool isValid() const { if (!Shortcut::isValid())