From 9539a892eb5bdcf252eedfb7d858c9a1c4489c96 Mon Sep 17 00:00:00 2001 From: Rajendra Singh Date: Thu, 13 Jun 2019 21:24:42 +0530 Subject: [PATCH] Code quality improvement: pass string by reference instead of value Also remove not implemented methods addBufferToView(), moveBuffer() and doActionOrNot() from Notepad_plus.h Close #5784 --- PowerEditor/src/Notepad_plus.cpp | 2 +- PowerEditor/src/Notepad_plus.h | 7 ++----- PowerEditor/src/Notepad_plus_Window.h | 2 +- PowerEditor/src/NppIO.cpp | 2 +- PowerEditor/src/Parameters.cpp | 12 +++++------ PowerEditor/src/Parameters.h | 20 +++++++++---------- .../src/ScitillaComponent/AutoCompletion.cpp | 14 ++++++------- PowerEditor/src/ScitillaComponent/Buffer.h | 2 +- .../src/ScitillaComponent/FindReplaceDlg.cpp | 2 +- .../src/ScitillaComponent/FindReplaceDlg.h | 2 +- .../src/WinControls/AboutDlg/AboutDlg.h | 2 +- .../WinControls/ColourPicker/WordStyleDlg.cpp | 2 +- .../WinControls/ColourPicker/WordStyleDlg.h | 2 +- .../src/WinControls/ContextMenu/ContextMenu.h | 2 +- .../WinControls/FileBrowser/fileBrowser.cpp | 2 +- .../src/WinControls/FileBrowser/fileBrowser.h | 2 +- .../WinControls/PluginsAdmin/pluginsAdmin.cpp | 6 +++--- .../WinControls/PluginsAdmin/pluginsAdmin.h | 10 +++++----- .../WinControls/Preference/preferenceDlg.h | 2 +- .../WinControls/StaticDialog/RunDlg/RunDlg.h | 2 +- .../src/WinControls/TaskList/TaskListDlg.h | 2 +- PowerEditor/src/WinControls/ToolBar/ToolBar.h | 2 +- 22 files changed, 49 insertions(+), 52 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 045b1d30..9f2132c5 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -5026,7 +5026,7 @@ bool Notepad_plus::str2Cliboard(const generic_string & str2cpy) //ONLY CALL IN CASE OF EMERGENCY: EXCEPTION //This function is destructive -bool Notepad_plus::emergency(generic_string emergencySavedDir) +bool Notepad_plus::emergency(const generic_string& emergencySavedDir) { ::CreateDirectory(emergencySavedDir.c_str(), NULL); return dumpFiles(emergencySavedDir.c_str(), TEXT("File")); diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index d28a80c4..83e10d7b 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -197,8 +197,6 @@ public: bool fileDelete(BufferID id = BUFFER_INVALID); bool fileRename(BufferID id = BUFFER_INVALID); - bool addBufferToView(BufferID id, int whichOne); - bool moveBuffer(BufferID id, int whereTo); //assumes whereFrom is otherView(whereTo) bool switchToFile(BufferID buffer); //find buffer in active view then in other view. //@} @@ -246,7 +244,7 @@ public: HACCEL getAccTable() const{ return _accelerator.getAccTable(); } - bool emergency(generic_string emergencySavedDir); + bool emergency(const generic_string& emergencySavedDir); Buffer* getCurrentBuffer() { return _pEditView->getCurrentBuffer(); } @@ -447,7 +445,6 @@ private: int doReloadOrNot(const TCHAR *fn, bool dirty); int doCloseOrNot(const TCHAR *fn); int doDeleteOrNot(const TCHAR *fn); - int doActionOrNot(const TCHAR *title, const TCHAR *displayText, int type); void enableMenu(int cmdID, bool doEnable) const; void enableCommand(int cmdID, bool doEnable, int which) const; @@ -570,7 +567,7 @@ private: int getLangFromMenuName(const TCHAR * langName); generic_string getLangFromMenu(const Buffer * buf); - generic_string exts2Filters(generic_string exts) const; + generic_string exts2Filters(const generic_string& exts) const; int setFileOpenSaveDlgFilters(FileDialog & fDlg, int langType = -1); Style * getStyleFromName(const TCHAR *styleName); bool dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix = TEXT("")); //helper func diff --git a/PowerEditor/src/Notepad_plus_Window.h b/PowerEditor/src/Notepad_plus_Window.h index 6e8beded..941c48e6 100644 --- a/PowerEditor/src/Notepad_plus_Window.h +++ b/PowerEditor/src/Notepad_plus_Window.h @@ -77,7 +77,7 @@ public: return _notepad_plus_plus_core.getAccTable(); } - bool emergency(generic_string emergencySavedDir) + bool emergency(const generic_string& emergencySavedDir) { return _notepad_plus_plus_core.emergency(emergencySavedDir); } diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index ee59c910..c11f017c 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -728,7 +728,7 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup) return; } -generic_string Notepad_plus::exts2Filters(generic_string exts) const +generic_string Notepad_plus::exts2Filters(const generic_string& exts) const { const TCHAR *extStr = exts.c_str(); TCHAR aExt[MAX_PATH]; diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 78dfb95b..19a9c417 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -691,7 +691,7 @@ std::wstring LocalizationSwitcher::getXmlFilePathFromLangName(const wchar_t *lan } -bool LocalizationSwitcher::addLanguageFromXml(wstring xmlFullPath) +bool LocalizationSwitcher::addLanguageFromXml(const std::wstring& xmlFullPath) { wchar_t * fn = ::PathFindFileNameW(xmlFullPath.c_str()); wstring foundLang = getLangFromXmlFileName(fn); @@ -1599,7 +1599,7 @@ void NppParameters::setFontList(HWND hWnd) ::EnumFontFamiliesEx(hDC, &lf, EnumFontFamExProc, reinterpret_cast(&_fontlist), 0); } -bool NppParameters::isInFontList(const generic_string fontName2Search) const +bool NppParameters::isInFontList(const generic_string& fontName2Search) const { if (fontName2Search.empty()) return false; @@ -1826,7 +1826,7 @@ bool NppParameters::reloadContextMenuFromXmlTree(HMENU mainMenuHadle, HMENU plug return getContextMenuFromXmlTree(mainMenuHadle, pluginsMenu); } -int NppParameters::getCmdIdFromMenuEntryItemName(HMENU mainMenuHadle, generic_string menuEntryName, generic_string menuItemName) +int NppParameters::getCmdIdFromMenuEntryItemName(HMENU mainMenuHadle, const generic_string& menuEntryName, const generic_string& menuItemName) { int nbMenuEntry = ::GetMenuItemCount(mainMenuHadle); for (int i = 0; i < nbMenuEntry; ++i) @@ -1886,7 +1886,7 @@ int NppParameters::getCmdIdFromMenuEntryItemName(HMENU mainMenuHadle, generic_st return -1; } -int NppParameters::getPluginCmdIdFromMenuEntryItemName(HMENU pluginsMenu, generic_string pluginName, generic_string pluginCmdName) +int NppParameters::getPluginCmdIdFromMenuEntryItemName(HMENU pluginsMenu, const generic_string& pluginName, const generic_string& pluginCmdName) { int nbPlugins = ::GetMenuItemCount(pluginsMenu); for (int i = 0; i < nbPlugins; ++i) @@ -2676,7 +2676,7 @@ std::pair NppParameters::feedUserLang(TiXmlNode *n return pair(iBegin, iEnd); } -bool NppParameters::importUDLFromFile(generic_string sourceFile) +bool NppParameters::importUDLFromFile(const generic_string& sourceFile) { TiXmlDocument *pXmlUserLangDoc = new TiXmlDocument(sourceFile); bool loadOkay = pXmlUserLangDoc->LoadFile(); @@ -2696,7 +2696,7 @@ bool NppParameters::importUDLFromFile(generic_string sourceFile) return loadOkay; } -bool NppParameters::exportUDLToFile(size_t langIndex2export, generic_string fileName2save) +bool NppParameters::exportUDLToFile(size_t langIndex2export, const generic_string& fileName2save) { if (langIndex2export >= NB_MAX_USER_LANG) return false; diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 6e69d324..825e5305 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -620,7 +620,7 @@ struct LangMenuItem final int _cmdID; generic_string _langName; - LangMenuItem(LangType lt, int cmdID = 0, generic_string langName = TEXT("")): + LangMenuItem(LangType lt, int cmdID = 0, const generic_string& langName = TEXT("")): _langType(lt), _cmdID(cmdID), _langName(langName){}; }; @@ -1170,7 +1170,7 @@ public: const wchar_t *_xmlFileName; }; - bool addLanguageFromXml(std::wstring xmlFullPath); + bool addLanguageFromXml(const std::wstring& xmlFullPath); std::wstring getLangFromXmlFileName(const wchar_t *fn) const; std::wstring getXmlFilePathFromLangName(const wchar_t *langName) const; @@ -1211,12 +1211,12 @@ class ThemeSwitcher final friend class NppParameters; public: - void addThemeFromXml(generic_string xmlFullPath) + void addThemeFromXml(const generic_string& xmlFullPath) { _themeList.push_back(std::pair(getThemeFromXmlFileName(xmlFullPath.c_str()), xmlFullPath)); } - void addDefaultThemeFromXml(generic_string xmlFullPath) + void addDefaultThemeFromXml(const generic_string& xmlFullPath) { _themeList.push_back(std::pair(TEXT("Default (stylers.xml)"), xmlFullPath)); } @@ -1407,7 +1407,7 @@ public: void setCurLineHilitingColour(COLORREF colour2Set); void setFontList(HWND hWnd); - bool isInFontList(const generic_string fontName2Search) const; + bool isInFontList(const generic_string& fontName2Search) const; const std::vector& getFontList() const { return _fontlist; } int getNbUserLang() const {return _nbUserLang;} @@ -1519,7 +1519,7 @@ public: void setWorkingDir(const TCHAR * newPath); - void setStartWithLocFileName(generic_string locPath) { + void setStartWithLocFileName(const generic_string& locPath) { _startWithLocFileName = locPath; }; @@ -1585,8 +1585,8 @@ public: } PluginList & getPluginList() {return _pluginList;}; - bool importUDLFromFile(generic_string sourceFile); - bool exportUDLToFile(size_t langIndex2export, generic_string fileName2save); + bool importUDLFromFile(const generic_string& sourceFile); + bool exportUDLToFile(size_t langIndex2export, const generic_string& fileName2save); NativeLangSpeaker* getNativeLangSpeaker() { return _pNativeLangSpeaker; } @@ -1827,8 +1827,8 @@ private: void writePrintSetting(TiXmlElement *element); void initMenuKeys(); //initialise menu keys and scintilla keys. Other keys are initialized on their own void initScintillaKeys(); //these functions have to be called first before any modifications are loaded - int getCmdIdFromMenuEntryItemName(HMENU mainMenuHadle, generic_string menuEntryName, generic_string menuItemName); // return -1 if not found - int getPluginCmdIdFromMenuEntryItemName(HMENU pluginsMenu, generic_string pluginName, generic_string pluginCmdName); // return -1 if not found + int getCmdIdFromMenuEntryItemName(HMENU mainMenuHadle, const generic_string& menuEntryName, const generic_string& menuItemName); // return -1 if not found + int getPluginCmdIdFromMenuEntryItemName(HMENU pluginsMenu, const generic_string& pluginName, const generic_string& pluginCmdName); // return -1 if not found winVer getWindowsVersion(); }; diff --git a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp index c078391e..497cb5e0 100644 --- a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp +++ b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp @@ -33,7 +33,7 @@ using namespace std; -static bool isInList(generic_string word, const vector & wordArray) +static bool isInList(const generic_string& word, const vector & wordArray) { for (size_t i = 0, len = wordArray.size(); i < len; ++i) if (wordArray[i] == word) @@ -171,7 +171,7 @@ void AutoCompletion::getWordArray(vector & wordArray, TCHAR *beg } } -static generic_string addTrailingSlash(generic_string path) +static generic_string addTrailingSlash(const generic_string& path) { if (path.length() >=1 && path[path.length() - 1] == '\\') return path; @@ -179,7 +179,7 @@ static generic_string addTrailingSlash(generic_string path) return path + L"\\"; } -static generic_string removeTrailingSlash(generic_string path) +static generic_string removeTrailingSlash(const generic_string& path) { if (path.length() >= 1 && path[path.length() - 1] == '\\') return path.substr(0, path.length() - 1); @@ -187,13 +187,13 @@ static generic_string removeTrailingSlash(generic_string path) return path; } -static bool isDirectory(generic_string path) +static bool isDirectory(const generic_string& path) { DWORD type = ::GetFileAttributes(path.c_str()); return type != INVALID_FILE_ATTRIBUTES && (type & FILE_ATTRIBUTE_DIRECTORY); } -static bool isFile(generic_string path) +static bool isFile(const generic_string& path) { DWORD type = ::GetFileAttributes(path.c_str()); return type != INVALID_FILE_ATTRIBUTES && ! (type & FILE_ATTRIBUTE_DIRECTORY); @@ -205,7 +205,7 @@ static bool isAllowedBeforeDriveLetter(TCHAR c) return c == '\'' || c == '"' || c == '(' || std::isspace(c, loc); } -static bool getRawPath(generic_string input, generic_string &rawPath_out) +static bool getRawPath(const generic_string& input, generic_string &rawPath_out) { // Try to find a path in the given input. // Algorithm: look for a colon. The colon must be preceded by an alphabetic character. @@ -226,7 +226,7 @@ static bool getRawPath(generic_string input, generic_string &rawPath_out) return true; } -static bool getPathsForPathCompletion(generic_string input, generic_string &rawPath_out, generic_string &pathToMatch_out) +static bool getPathsForPathCompletion(const generic_string& input, generic_string &rawPath_out, generic_string &pathToMatch_out) { generic_string rawPath; if (! getRawPath(input, rawPath)) diff --git a/PowerEditor/src/ScitillaComponent/Buffer.h b/PowerEditor/src/ScitillaComponent/Buffer.h index 784f155b..7eb68bc3 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.h +++ b/PowerEditor/src/ScitillaComponent/Buffer.h @@ -326,7 +326,7 @@ public: bool isModified() const { return _isModified; } void setModifiedStatus(bool isModified) { _isModified = isModified; } generic_string getBackupFileName() const { return _backupFileName; } - void setBackupFileName(generic_string fileName) { _backupFileName = fileName; } + void setBackupFileName(const generic_string& fileName) { _backupFileName = fileName; } FILETIME getLastModifiedTimestamp() const { return _timeStamp; } bool isLoadedDirty() const diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 6517189d..c76bc44f 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -2570,7 +2570,7 @@ void FindReplaceDlg::setStatusbarMessage(const generic_string & msg, FindStatus } } -void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, generic_string stringValue) +void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, const generic_string& stringValue) { try { diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h index 93d4d51b..c4babc36 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h @@ -329,7 +329,7 @@ public : } }; - void execSavedCommand(int cmd, uptr_t intValue, generic_string stringValue); + void execSavedCommand(int cmd, uptr_t intValue, const generic_string& stringValue); void setStatusbarMessage(const generic_string & msg, FindStatus staus); Finder * createFinder(); bool removeFinder(Finder *finder2remove); diff --git a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.h b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.h index b5966c10..72c5b54f 100644 --- a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.h +++ b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.h @@ -74,7 +74,7 @@ class DebugInfoDlg : public StaticDialog public: DebugInfoDlg() : StaticDialog() {}; - void init(HINSTANCE hInst, HWND parent, bool isAdmin, generic_string loadedPlugins) { + void init(HINSTANCE hInst, HWND parent, bool isAdmin, const generic_string& loadedPlugins) { _isAdmin = isAdmin; _loadedPlugins = loadedPlugins; Window::init(hInst, parent); diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index fa5be2b5..07767d78 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -482,7 +482,7 @@ void WordStyleDlg::loadLangListFromNppParam() setStyleListFromLexer(index2Begin); } -void WordStyleDlg::updateThemeName(generic_string themeName) +void WordStyleDlg::updateThemeName(const generic_string& themeName) { NppParameters *pNppParam = NppParameters::getInstance(); NppGUI & nppGUI = (NppGUI & )pNppParam->getNppGUI(); diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h index 2e94c4e5..36005981 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h @@ -182,7 +182,7 @@ private : void updateFontSize(); void updateUserKeywords(); void switchToTheme(); - void updateThemeName(generic_string themeName); + void updateThemeName(const generic_string& themeName); void loadLangListFromNppParam(); diff --git a/PowerEditor/src/WinControls/ContextMenu/ContextMenu.h b/PowerEditor/src/WinControls/ContextMenu/ContextMenu.h index ce8c72bf..8dd6df15 100644 --- a/PowerEditor/src/WinControls/ContextMenu/ContextMenu.h +++ b/PowerEditor/src/WinControls/ContextMenu/ContextMenu.h @@ -36,7 +36,7 @@ struct MenuItemUnit final generic_string _parentFolderName; MenuItemUnit() = default; - MenuItemUnit(unsigned long cmdID, generic_string itemName, generic_string parentFolderName = generic_string()) + MenuItemUnit(unsigned long cmdID, const generic_string& itemName, const generic_string& parentFolderName = generic_string()) : _cmdID(cmdID), _itemName(itemName), _parentFolderName(parentFolderName){}; MenuItemUnit(unsigned long cmdID, const TCHAR *itemName, const TCHAR *parentFolderName = nullptr); }; diff --git a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp index 83c01e37..b376f991 100644 --- a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp +++ b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp @@ -990,7 +990,7 @@ HTREEITEM FileBrowser::getRootFromFullPath(const generic_string & rootPath) cons return node; } -HTREEITEM FileBrowser::findChildNodeFromName(HTREEITEM parent, generic_string label) +HTREEITEM FileBrowser::findChildNodeFromName(HTREEITEM parent, const generic_string& label) { HTREEITEM childNodeFound = nullptr; diff --git a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.h b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.h index e684c584..df3bfd1d 100644 --- a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.h +++ b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.h @@ -147,7 +147,7 @@ public: void addRootFolder(generic_string); HTREEITEM getRootFromFullPath(const generic_string & rootPath) const; - HTREEITEM findChildNodeFromName(HTREEITEM parent, generic_string); + HTREEITEM findChildNodeFromName(HTREEITEM parent, const generic_string&); bool addInTree(const generic_string& rootPath, const generic_string& addItemFullPath, HTREEITEM node, std::vector linarPathArray); HTREEITEM findInTree(const generic_string& rootPath, HTREEITEM node, std::vector linarPathArray); diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp index d1aa1984..2e83a73f 100644 --- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp +++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp @@ -78,7 +78,7 @@ Version::Version(const generic_string& versionStr) } } -void Version::setVersionFrom(generic_string filePath) +void Version::setVersionFrom(const generic_string& filePath) { if (not filePath.empty() && ::PathFileExists(filePath.c_str())) { @@ -215,7 +215,7 @@ bool findStrNoCase(const generic_string & strHaystack, const generic_string & st return (it != strHaystack.end()); } -bool PluginsAdminDlg::isFoundInAvailableListFromIndex(int index, generic_string str2search, bool inWhichPart) const +bool PluginsAdminDlg::isFoundInAvailableListFromIndex(int index, const generic_string& str2search, bool inWhichPart) const { PluginUpdateInfo* pui = _availableList.getPluginInfoFromUiIndex(index); generic_string searchIn; @@ -227,7 +227,7 @@ bool PluginsAdminDlg::isFoundInAvailableListFromIndex(int index, generic_string return (findStrNoCase(searchIn, str2search)); } -long PluginsAdminDlg::searchFromCurrentSel(generic_string str2search, bool inWhichPart, bool isNextMode) const +long PluginsAdminDlg::searchFromCurrentSel(const generic_string& str2search, bool inWhichPart, bool isNextMode) const { // search from curent selected item or from the beginning long currentIndex = _availableList.getSelectedIndex(); diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h index a3f50d6a..80f55625 100644 --- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h +++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h @@ -47,7 +47,7 @@ struct Version Version() {}; Version(const generic_string& versionStr); - void setVersionFrom(generic_string filePath); + void setVersionFrom(const generic_string& filePath); generic_string toString(); bool isNumber(const generic_string& s) const { return !s.empty() && @@ -229,13 +229,13 @@ private : bool searchInPlugins(bool isNextMode) const; const bool _inNames = true; const bool _inDescs = false; - bool isFoundInAvailableListFromIndex(int index, generic_string str2search, bool inWhichPart) const; - long searchFromCurrentSel(generic_string str2search, bool inWhichPart, bool isNextMode) const; - long searchInNamesFromCurrentSel(generic_string str2search, bool isNextMode) const { + bool isFoundInAvailableListFromIndex(int index, const generic_string& str2search, bool inWhichPart) const; + long searchFromCurrentSel(const generic_string& str2search, bool inWhichPart, bool isNextMode) const; + long searchInNamesFromCurrentSel(const generic_string& str2search, bool isNextMode) const { return searchFromCurrentSel(str2search, _inNames, isNextMode); }; - long searchInDescsFromCurrentSel(generic_string str2search, bool isNextMode) const { + long searchInDescsFromCurrentSel(const generic_string& str2search, bool isNextMode) const { return searchFromCurrentSel(str2search, _inDescs, isNextMode); }; diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.h b/PowerEditor/src/WinControls/Preference/preferenceDlg.h index 5d54ebeb..d01f62a1 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.h +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.h @@ -70,7 +70,7 @@ struct LangID_Name { LangType _id; generic_string _name; - LangID_Name(LangType id, generic_string name) : _id(id), _name(name){}; + LangID_Name(LangType id, const generic_string& name) : _id(id), _name(name){}; }; class DefaultNewDocDlg : public StaticDialog diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h index b79f4d2f..e7ef0e1f 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h @@ -41,7 +41,7 @@ class Command { public : Command(){}; explicit Command(TCHAR *cmd) : _cmdLine(cmd){}; - explicit Command(generic_string cmd) : _cmdLine(cmd){}; + explicit Command(const generic_string& cmd) : _cmdLine(cmd){}; HINSTANCE run(HWND hWnd); HINSTANCE run(HWND hWnd, const TCHAR* cwd); diff --git a/PowerEditor/src/WinControls/TaskList/TaskListDlg.h b/PowerEditor/src/WinControls/TaskList/TaskListDlg.h index 62d50a0b..ea63c32a 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskListDlg.h +++ b/PowerEditor/src/WinControls/TaskList/TaskListDlg.h @@ -43,7 +43,7 @@ struct TaskLstFnStatus { generic_string _fn; int _status = 0; void *_bufID = nullptr; - TaskLstFnStatus(generic_string str, int status) : _fn(str), _status(status){}; + TaskLstFnStatus(const generic_string& str, int status) : _fn(str), _status(status){}; TaskLstFnStatus(int iView, int docIndex, generic_string str, int status, void *bufID) : _iView(iView), _docIndex(docIndex), _fn(str), _status(status), _bufID(bufID) {}; }; diff --git a/PowerEditor/src/WinControls/ToolBar/ToolBar.h b/PowerEditor/src/WinControls/ToolBar/ToolBar.h index fd8f91fe..cb639e02 100644 --- a/PowerEditor/src/WinControls/ToolBar/ToolBar.h +++ b/PowerEditor/src/WinControls/ToolBar/ToolBar.h @@ -56,7 +56,7 @@ struct iconLocator { int iconIndex; generic_string iconLocation; - iconLocator(int iList, int iIcon, const generic_string iconLoc) + iconLocator(int iList, int iIcon, const generic_string& iconLoc) : listIndex(iList), iconIndex(iIcon), iconLocation(iconLoc){}; };