Pass the arguments by reference instead of by copy to improve the performance

Close #5341
This commit is contained in:
Rajendra Singh 2019-02-25 00:49:58 +05:30 committed by Don HO
parent 3baef49079
commit 2a4a70ed21
7 changed files with 29 additions and 29 deletions

View File

@ -162,7 +162,7 @@ private:
struct sessionFileInfo : public Position
{
sessionFileInfo(const TCHAR *fn, const TCHAR *ln, int encoding, Position pos, const TCHAR *backupFilePath, FILETIME originalFileLastModifTimestamp, const MapPosition & mapPos) :
sessionFileInfo(const TCHAR *fn, const TCHAR *ln, int encoding, const Position& pos, const TCHAR *backupFilePath, FILETIME originalFileLastModifTimestamp, const MapPosition & mapPos) :
_encoding(encoding), Position(pos), _originalFileLastModifTimestamp(originalFileLastModifTimestamp), _mapPos(mapPos)
{
if (fn) _fileName = fn;

View File

@ -1027,7 +1027,7 @@ generic_string FileBrowser::getSelectedItemPath() const
return itemPath;
}
bool FileBrowser::addInTree(generic_string rootPath, generic_string addItemFullPath, HTREEITEM node, vector<generic_string> linarPathArray)
bool FileBrowser::addInTree(const generic_string& rootPath, const generic_string& addItemFullPath, HTREEITEM node, vector<generic_string> linarPathArray)
{
if (node == nullptr) // it's a root. Search the right root with rootPath
{
@ -1083,7 +1083,7 @@ bool FileBrowser::addInTree(generic_string rootPath, generic_string addItemFullP
}
}
HTREEITEM FileBrowser::findInTree(generic_string rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray)
HTREEITEM FileBrowser::findInTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray)
{
if (node == nullptr) // it's a root. Search the right root with rootPath
{
@ -1122,7 +1122,7 @@ HTREEITEM FileBrowser::findInTree(generic_string rootPath, HTREEITEM node, std::
}
}
bool FileBrowser::deleteFromTree(generic_string rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray)
bool FileBrowser::deleteFromTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray)
{
HTREEITEM foundItem = findInTree(rootPath, node, linarPathArray);
if (foundItem == nullptr)
@ -1133,7 +1133,7 @@ bool FileBrowser::deleteFromTree(generic_string rootPath, HTREEITEM node, std::v
return true;
}
bool FileBrowser::renameInTree(generic_string rootPath, HTREEITEM node, std::vector<generic_string> linarPathArrayFrom, const generic_string & renameTo)
bool FileBrowser::renameInTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArrayFrom, const generic_string & renameTo)
{
HTREEITEM foundItem = findInTree(rootPath, node, linarPathArrayFrom);
if (foundItem == nullptr)

View File

@ -75,11 +75,11 @@ friend class FolderUpdater;
public:
FolderInfo(const generic_string & name, FolderInfo *parent) : _name(name), _parent(parent) {};
void setRootPath(generic_string rootPath) { _rootPath = rootPath; };
void setRootPath(const generic_string& rootPath) { _rootPath = rootPath; };
generic_string getRootPath() const { return _rootPath; };
void setName(generic_string name) { _name = name; };
void setName(const generic_string& name) { _name = name; };
generic_string getName() const { return _name; };
void addFile(generic_string fn) { _files.push_back(FileInfo(fn, this)); };
void addFile(const generic_string& fn) { _files.push_back(FileInfo(fn, this)); };
void addSubFolder(FolderInfo subDirectoryStructure) { _subFolders.push_back(subDirectoryStructure); };
bool addToStructure(generic_string & fullpath, std::vector<generic_string> linarPathArray);
@ -147,10 +147,10 @@ public:
HTREEITEM getRootFromFullPath(const generic_string & rootPath) const;
HTREEITEM findChildNodeFromName(HTREEITEM parent, generic_string);
bool addInTree(generic_string rootPath, generic_string addItemFullPath, HTREEITEM node, std::vector<generic_string> linarPathArray);
HTREEITEM findInTree(generic_string rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray);
bool deleteFromTree(generic_string rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray);
bool renameInTree(generic_string rootPath, HTREEITEM node, std::vector<generic_string> linarPathArrayFrom, const generic_string & renameTo);
bool addInTree(const generic_string& rootPath, const generic_string& addItemFullPath, HTREEITEM node, std::vector<generic_string> linarPathArray);
HTREEITEM findInTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray);
bool deleteFromTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray);
bool renameInTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArrayFrom, const generic_string & renameTo);
std::vector<generic_string> getRoots() const;
generic_string getSelectedItemPath() const;

View File

@ -43,7 +43,7 @@ FunctionParsersManager::~FunctionParsersManager()
delete _pXmlFuncListDoc;
}
bool FunctionParsersManager::init(generic_string xmlPath, ScintillaEditView ** ppEditView)
bool FunctionParsersManager::init(const generic_string& xmlPath, ScintillaEditView ** ppEditView)
{
_ppEditView = ppEditView;
bool loadOkay = false;

View File

@ -43,7 +43,7 @@ class FunctionParser
{
friend class FunctionParsersManager;
public:
FunctionParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr, generic_string functionExpr, std::vector<generic_string> functionNameExprArray, std::vector<generic_string> classNameExprArray):
FunctionParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr, const generic_string& functionExpr, const std::vector<generic_string>& functionNameExprArray, const std::vector<generic_string>& classNameExprArray):
_id(id), _displayName(displayName), _commentExpr(commentExpr?commentExpr:TEXT("")), _functionExpr(functionExpr), _functionNameExprArray(functionNameExprArray), _classNameExprArray(classNameExprArray){};
virtual void parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT("")) = 0;
@ -66,8 +66,8 @@ protected:
class FunctionZoneParser : public FunctionParser
{
public:
FunctionZoneParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr, generic_string rangeExpr, generic_string openSymbole, generic_string closeSymbole,
std::vector<generic_string> classNameExprArray, generic_string functionExpr, std::vector<generic_string> functionNameExprArray):
FunctionZoneParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr, const generic_string& rangeExpr, const generic_string& openSymbole, const generic_string& closeSymbole,
const std::vector<generic_string>& classNameExprArray, const generic_string& functionExpr, const std::vector<generic_string>& functionNameExprArray):
FunctionParser(id, displayName, commentExpr, functionExpr, functionNameExprArray, classNameExprArray), _rangeExpr(rangeExpr), _openSymbole(openSymbole), _closeSymbole(closeSymbole) {};
void parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT(""));
@ -89,8 +89,8 @@ class FunctionUnitParser : public FunctionParser
{
public:
FunctionUnitParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr,
generic_string mainExpr, std::vector<generic_string> functionNameExprArray,
std::vector<generic_string> classNameExprArray): FunctionParser(id, displayName, commentExpr, mainExpr, functionNameExprArray, classNameExprArray)
const generic_string& mainExpr, const std::vector<generic_string>& functionNameExprArray,
const std::vector<generic_string>& classNameExprArray): FunctionParser(id, displayName, commentExpr, mainExpr, functionNameExprArray, classNameExprArray)
{}
void parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT(""));
@ -99,8 +99,8 @@ public:
class FunctionMixParser : public FunctionZoneParser
{
public:
FunctionMixParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr, generic_string rangeExpr, generic_string openSymbole, generic_string closeSymbole,
std::vector<generic_string> classNameExprArray, generic_string functionExpr, std::vector<generic_string> functionNameExprArray, FunctionUnitParser *funcUnitPaser):
FunctionMixParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr, const generic_string& rangeExpr, const generic_string& openSymbole, const generic_string& closeSymbole,
const std::vector<generic_string>& classNameExprArray, const generic_string& functionExpr, const std::vector<generic_string>& functionNameExprArray, FunctionUnitParser *funcUnitPaser):
FunctionZoneParser(id, displayName, commentExpr, rangeExpr, openSymbole, closeSymbole, classNameExprArray, functionExpr, functionNameExprArray), _funcUnitPaser(funcUnitPaser){};
~FunctionMixParser()
@ -143,7 +143,7 @@ class FunctionParsersManager final
public:
~FunctionParsersManager();
bool init(generic_string xmlPath, ScintillaEditView ** ppEditView);
bool init(const generic_string& xmlPath, ScintillaEditView ** ppEditView);
bool parse(std::vector<foundInfo> & foundInfos, const AssociationInfo & assoInfo);
void writeFunctionListXml(const TCHAR *destFoder) const;

View File

@ -611,7 +611,7 @@ void Accelerator::updateFullMenu() {
::DrawMenuBar(_hMenuParent);
}
void Accelerator::updateMenuItemByCommand(CommandShortcut csc)
void Accelerator::updateMenuItemByCommand(const CommandShortcut& csc)
{
int cmdID = csc.getID();
@ -887,7 +887,7 @@ void ScintillaAccelerator::updateKeys()
}
}
void ScintillaAccelerator::updateMenuItemByID(ScintillaKeyMap skm, int id)
void ScintillaAccelerator::updateMenuItemByID(const ScintillaKeyMap& skm, int id)
{
const int commandSize = 64;
TCHAR cmdName[commandSize];
@ -1107,7 +1107,7 @@ INT_PTR CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARA
//return FALSE;
}
CommandShortcut::CommandShortcut(Shortcut sc, long id) : Shortcut(sc), _id(id) {
CommandShortcut::CommandShortcut(const Shortcut& sc, long id) : Shortcut(sc), _id(id) {
if ( _id < IDM_EDIT)
_category = TEXT("File");
else if ( _id < IDM_SEARCH)

View File

@ -194,7 +194,7 @@ protected :
class CommandShortcut : public Shortcut {
public:
CommandShortcut(Shortcut sc, long id);
CommandShortcut(const Shortcut& sc, long id);
unsigned long getID() const {return _id;};
void setID(unsigned long id) { _id = id;};
const TCHAR * getCategory() const { return _category.c_str(); };
@ -207,7 +207,7 @@ private :
class ScintillaKeyMap : public Shortcut {
public:
ScintillaKeyMap(Shortcut sc, unsigned long scintillaKeyID, unsigned long id): Shortcut(sc), _menuCmdID(id), _scintillaKeyID(scintillaKeyID) {
ScintillaKeyMap(const Shortcut& sc, unsigned long scintillaKeyID, unsigned long id): Shortcut(sc), _menuCmdID(id), _scintillaKeyID(scintillaKeyID) {
_keyCombos.clear();
_keyCombos.push_back(_keyCombo);
_keyCombo._key = 0;
@ -311,7 +311,7 @@ typedef std::vector<recordedMacroStep> Macro;
class MacroShortcut : public CommandShortcut {
friend class NppParameters;
public:
MacroShortcut(Shortcut sc, Macro macro, int id) : CommandShortcut(sc, id), _macro(macro) {_canModifyName = true;};
MacroShortcut(const Shortcut& sc, const Macro& macro, int id) : CommandShortcut(sc, id), _macro(macro) {_canModifyName = true;};
Macro & getMacro() {return _macro;};
private:
Macro _macro;
@ -384,7 +384,7 @@ private:
ACCEL *_pAccelArray = nullptr;
int _nbAccelItems = 0;
void updateMenuItemByCommand(CommandShortcut csc);
void updateMenuItemByCommand(const CommandShortcut& csc);
};
class ScintillaAccelerator { //Handles accelerator keys for scintilla
@ -398,5 +398,5 @@ private:
HWND _hMenuParent = nullptr;
std::vector<HWND> _vScintillas;
void updateMenuItemByID(ScintillaKeyMap skm, int id);
void updateMenuItemByID(const ScintillaKeyMap& skm, int id);
};