Pass the arguments by reference instead of by copy to improve the performance
Close #5341
This commit is contained in:
parent
3baef49079
commit
2a4a70ed21
@ -162,7 +162,7 @@ private:
|
|||||||
|
|
||||||
struct sessionFileInfo : public Position
|
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)
|
_encoding(encoding), Position(pos), _originalFileLastModifTimestamp(originalFileLastModifTimestamp), _mapPos(mapPos)
|
||||||
{
|
{
|
||||||
if (fn) _fileName = fn;
|
if (fn) _fileName = fn;
|
||||||
|
@ -1027,7 +1027,7 @@ generic_string FileBrowser::getSelectedItemPath() const
|
|||||||
return itemPath;
|
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
|
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
|
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);
|
HTREEITEM foundItem = findInTree(rootPath, node, linarPathArray);
|
||||||
if (foundItem == nullptr)
|
if (foundItem == nullptr)
|
||||||
@ -1133,7 +1133,7 @@ bool FileBrowser::deleteFromTree(generic_string rootPath, HTREEITEM node, std::v
|
|||||||
return true;
|
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);
|
HTREEITEM foundItem = findInTree(rootPath, node, linarPathArrayFrom);
|
||||||
if (foundItem == nullptr)
|
if (foundItem == nullptr)
|
||||||
|
@ -75,11 +75,11 @@ friend class FolderUpdater;
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
FolderInfo(const generic_string & name, FolderInfo *parent) : _name(name), _parent(parent) {};
|
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; };
|
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; };
|
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); };
|
void addSubFolder(FolderInfo subDirectoryStructure) { _subFolders.push_back(subDirectoryStructure); };
|
||||||
|
|
||||||
bool addToStructure(generic_string & fullpath, std::vector<generic_string> linarPathArray);
|
bool addToStructure(generic_string & fullpath, std::vector<generic_string> linarPathArray);
|
||||||
@ -147,10 +147,10 @@ public:
|
|||||||
HTREEITEM getRootFromFullPath(const generic_string & rootPath) const;
|
HTREEITEM getRootFromFullPath(const generic_string & rootPath) const;
|
||||||
HTREEITEM findChildNodeFromName(HTREEITEM parent, generic_string);
|
HTREEITEM findChildNodeFromName(HTREEITEM parent, generic_string);
|
||||||
|
|
||||||
bool addInTree(generic_string rootPath, generic_string addItemFullPath, HTREEITEM node, std::vector<generic_string> linarPathArray);
|
bool addInTree(const generic_string& rootPath, const generic_string& addItemFullPath, HTREEITEM node, std::vector<generic_string> linarPathArray);
|
||||||
HTREEITEM findInTree(generic_string rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray);
|
HTREEITEM findInTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray);
|
||||||
bool deleteFromTree(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(generic_string rootPath, HTREEITEM node, std::vector<generic_string> linarPathArrayFrom, const generic_string & renameTo);
|
bool renameInTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArrayFrom, const generic_string & renameTo);
|
||||||
|
|
||||||
std::vector<generic_string> getRoots() const;
|
std::vector<generic_string> getRoots() const;
|
||||||
generic_string getSelectedItemPath() const;
|
generic_string getSelectedItemPath() const;
|
||||||
|
@ -43,7 +43,7 @@ FunctionParsersManager::~FunctionParsersManager()
|
|||||||
delete _pXmlFuncListDoc;
|
delete _pXmlFuncListDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FunctionParsersManager::init(generic_string xmlPath, ScintillaEditView ** ppEditView)
|
bool FunctionParsersManager::init(const generic_string& xmlPath, ScintillaEditView ** ppEditView)
|
||||||
{
|
{
|
||||||
_ppEditView = ppEditView;
|
_ppEditView = ppEditView;
|
||||||
bool loadOkay = false;
|
bool loadOkay = false;
|
||||||
|
@ -43,7 +43,7 @@ class FunctionParser
|
|||||||
{
|
{
|
||||||
friend class FunctionParsersManager;
|
friend class FunctionParsersManager;
|
||||||
public:
|
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){};
|
_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;
|
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
|
class FunctionZoneParser : public FunctionParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FunctionZoneParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr, generic_string rangeExpr, generic_string openSymbole, generic_string closeSymbole,
|
FunctionZoneParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr, const generic_string& rangeExpr, const generic_string& openSymbole, const generic_string& closeSymbole,
|
||||||
std::vector<generic_string> classNameExprArray, generic_string functionExpr, std::vector<generic_string> functionNameExprArray):
|
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) {};
|
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(""));
|
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:
|
public:
|
||||||
FunctionUnitParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr,
|
FunctionUnitParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr,
|
||||||
generic_string mainExpr, std::vector<generic_string> functionNameExprArray,
|
const generic_string& mainExpr, const std::vector<generic_string>& functionNameExprArray,
|
||||||
std::vector<generic_string> classNameExprArray): FunctionParser(id, displayName, commentExpr, mainExpr, functionNameExprArray, classNameExprArray)
|
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(""));
|
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
|
class FunctionMixParser : public FunctionZoneParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FunctionMixParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr, generic_string rangeExpr, generic_string openSymbole, generic_string closeSymbole,
|
FunctionMixParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr, const generic_string& rangeExpr, const generic_string& openSymbole, const generic_string& closeSymbole,
|
||||||
std::vector<generic_string> classNameExprArray, generic_string functionExpr, std::vector<generic_string> functionNameExprArray, FunctionUnitParser *funcUnitPaser):
|
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){};
|
FunctionZoneParser(id, displayName, commentExpr, rangeExpr, openSymbole, closeSymbole, classNameExprArray, functionExpr, functionNameExprArray), _funcUnitPaser(funcUnitPaser){};
|
||||||
|
|
||||||
~FunctionMixParser()
|
~FunctionMixParser()
|
||||||
@ -143,7 +143,7 @@ class FunctionParsersManager final
|
|||||||
public:
|
public:
|
||||||
~FunctionParsersManager();
|
~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);
|
bool parse(std::vector<foundInfo> & foundInfos, const AssociationInfo & assoInfo);
|
||||||
void writeFunctionListXml(const TCHAR *destFoder) const;
|
void writeFunctionListXml(const TCHAR *destFoder) const;
|
||||||
|
|
||||||
|
@ -611,7 +611,7 @@ void Accelerator::updateFullMenu() {
|
|||||||
::DrawMenuBar(_hMenuParent);
|
::DrawMenuBar(_hMenuParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accelerator::updateMenuItemByCommand(CommandShortcut csc)
|
void Accelerator::updateMenuItemByCommand(const CommandShortcut& csc)
|
||||||
{
|
{
|
||||||
int cmdID = csc.getID();
|
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;
|
const int commandSize = 64;
|
||||||
TCHAR cmdName[commandSize];
|
TCHAR cmdName[commandSize];
|
||||||
@ -1107,7 +1107,7 @@ INT_PTR CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARA
|
|||||||
//return FALSE;
|
//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)
|
if ( _id < IDM_EDIT)
|
||||||
_category = TEXT("File");
|
_category = TEXT("File");
|
||||||
else if ( _id < IDM_SEARCH)
|
else if ( _id < IDM_SEARCH)
|
||||||
|
@ -194,7 +194,7 @@ protected :
|
|||||||
|
|
||||||
class CommandShortcut : public Shortcut {
|
class CommandShortcut : public Shortcut {
|
||||||
public:
|
public:
|
||||||
CommandShortcut(Shortcut sc, long id);
|
CommandShortcut(const Shortcut& sc, long id);
|
||||||
unsigned long getID() const {return _id;};
|
unsigned long getID() const {return _id;};
|
||||||
void setID(unsigned long id) { _id = id;};
|
void setID(unsigned long id) { _id = id;};
|
||||||
const TCHAR * getCategory() const { return _category.c_str(); };
|
const TCHAR * getCategory() const { return _category.c_str(); };
|
||||||
@ -207,7 +207,7 @@ private :
|
|||||||
|
|
||||||
class ScintillaKeyMap : public Shortcut {
|
class ScintillaKeyMap : public Shortcut {
|
||||||
public:
|
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.clear();
|
||||||
_keyCombos.push_back(_keyCombo);
|
_keyCombos.push_back(_keyCombo);
|
||||||
_keyCombo._key = 0;
|
_keyCombo._key = 0;
|
||||||
@ -311,7 +311,7 @@ typedef std::vector<recordedMacroStep> Macro;
|
|||||||
class MacroShortcut : public CommandShortcut {
|
class MacroShortcut : public CommandShortcut {
|
||||||
friend class NppParameters;
|
friend class NppParameters;
|
||||||
public:
|
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;};
|
Macro & getMacro() {return _macro;};
|
||||||
private:
|
private:
|
||||||
Macro _macro;
|
Macro _macro;
|
||||||
@ -384,7 +384,7 @@ private:
|
|||||||
ACCEL *_pAccelArray = nullptr;
|
ACCEL *_pAccelArray = nullptr;
|
||||||
int _nbAccelItems = 0;
|
int _nbAccelItems = 0;
|
||||||
|
|
||||||
void updateMenuItemByCommand(CommandShortcut csc);
|
void updateMenuItemByCommand(const CommandShortcut& csc);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ScintillaAccelerator { //Handles accelerator keys for scintilla
|
class ScintillaAccelerator { //Handles accelerator keys for scintilla
|
||||||
@ -398,5 +398,5 @@ private:
|
|||||||
HWND _hMenuParent = nullptr;
|
HWND _hMenuParent = nullptr;
|
||||||
std::vector<HWND> _vScintillas;
|
std::vector<HWND> _vScintillas;
|
||||||
|
|
||||||
void updateMenuItemByID(ScintillaKeyMap skm, int id);
|
void updateMenuItemByID(const ScintillaKeyMap& skm, int id);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user