Code enhancement: Initialize member variables

This commit is contained in:
Don Ho 2022-02-09 04:40:16 +01:00
parent dee3bad29d
commit 2e9342ae24
12 changed files with 43 additions and 55 deletions

View File

@ -156,6 +156,9 @@ struct Position
struct MapPosition struct MapPosition
{ {
private:
intptr_t _maxPeekLenInKB = 512; // 512 KB
public:
intptr_t _firstVisibleDisplayLine = -1; intptr_t _firstVisibleDisplayLine = -1;
intptr_t _firstVisibleDocLine = -1; // map intptr_t _firstVisibleDocLine = -1; // map
@ -171,9 +174,6 @@ struct MapPosition
bool _isWrap = false; bool _isWrap = false;
bool isValid() const { return (_firstVisibleDisplayLine != -1); }; bool isValid() const { return (_firstVisibleDisplayLine != -1); };
bool canScroll() const { return (_KByteInDoc < _maxPeekLenInKB); }; // _nbCharInDoc < _maxPeekLen : Don't scroll the document for the performance issue bool canScroll() const { return (_KByteInDoc < _maxPeekLenInKB); }; // _nbCharInDoc < _maxPeekLen : Don't scroll the document for the performance issue
private:
intptr_t _maxPeekLenInKB = 512; // 512 KB
}; };

View File

@ -471,7 +471,7 @@ private :
FindStatus _findStatus = FSFound; FindStatus _findStatus = FSFound;
ReBar* _pRebar = nullptr; ReBar* _pRebar = nullptr;
REBARBANDINFO _rbBand; REBARBANDINFO _rbBand = { 0 };
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
void markSelectedTextInc(bool enable, FindOption *opt = NULL); void markSelectedTextInc(bool enable, FindOption *opt = NULL);

View File

@ -43,7 +43,7 @@ public :
size_t doPrint(bool justDoIt); size_t doPrint(bool justDoIt);
private : private :
PRINTDLG _pdlg; PRINTDLG _pdlg = { 0 };
ScintillaEditView *_pSEView = nullptr; ScintillaEditView *_pSEView = nullptr;
size_t _startPos = 0; size_t _startPos = 0;
size_t _endPos = 0; size_t _endPos = 0;

View File

@ -28,13 +28,6 @@ const Utf8_16::utf8 Utf8_16::k_Boms[][3] = {
// ================================================================== // ==================================================================
Utf8_16_Read::Utf8_16_Read() {
m_eEncoding = uni8Bit;
m_nAllocatedBufSize = 0;
m_nNewBufSize = 0;
m_pNewBuf = NULL;
m_bFirstRead = true;
}
Utf8_16_Read::~Utf8_16_Read() Utf8_16_Read::~Utf8_16_Read()
{ {

View File

@ -103,7 +103,7 @@ protected:
enum u78 {utf8NoBOM=0, ascii7bits=1, ascii8bits=2}; enum u78 {utf8NoBOM=0, ascii7bits=1, ascii8bits=2};
class Utf8_16_Read : public Utf8_16 { class Utf8_16_Read : public Utf8_16 {
public: public:
Utf8_16_Read(); Utf8_16_Read() {};
~Utf8_16_Read(); ~Utf8_16_Read();
size_t convert(char* buf, size_t len); size_t convert(char* buf, size_t len);
@ -118,16 +118,16 @@ protected:
u78 utf8_7bits_8bits(); u78 utf8_7bits_8bits();
private: private:
UniMode m_eEncoding; UniMode m_eEncoding = uni8Bit;
ubyte* m_pBuf; ubyte* m_pBuf = nullptr;
ubyte* m_pNewBuf; ubyte* m_pNewBuf = nullptr;
// size of the new buffer // size of the new buffer
size_t m_nNewBufSize; size_t m_nNewBufSize = 0;
// size of the previously allocated buffer (if != 0) // size of the previously allocated buffer (if != 0)
size_t m_nAllocatedBufSize; size_t m_nAllocatedBufSize = 0;
size_t m_nSkip; size_t m_nSkip = 0;
bool m_bFirstRead; bool m_bFirstRead = true;
size_t m_nLen; size_t m_nLen = 0;
Utf16_Iter m_Iter16; Utf16_Iter m_Iter16;
}; };

View File

@ -144,7 +144,7 @@ private:
ScintillaEditView**_ppEditView = nullptr; ScintillaEditView**_ppEditView = nullptr;
ScintillaEditView*_pMapView = nullptr; ScintillaEditView*_pMapView = nullptr;
ViewZoneDlg _vzDlg; ViewZoneDlg _vzDlg;
HWND _hwndScintilla; HWND _hwndScintilla = nullptr;
bool _isTemporarilyShowing = false; bool _isTemporarilyShowing = false;
// for needToRecomputeWith function // for needToRecomputeWith function

View File

@ -107,7 +107,7 @@ private:
TreeView _treeView; TreeView _treeView;
TreeView _treeViewSearchResult; TreeView _treeViewSearchResult;
SCROLLINFO si; SCROLLINFO si = { 0 };
long _findLine = -1; long _findLine = -1;
long _findEndLine = -1; long _findEndLine = -1;
HTREEITEM _findItem = nullptr; HTREEITEM _findItem = nullptr;

View File

@ -111,7 +111,7 @@ private :
size_t _nbTotalButtons = 0; size_t _nbTotalButtons = 0;
size_t _nbCurrentButtons = 0; size_t _nbCurrentButtons = 0;
ReBar * _pRebar = nullptr; ReBar * _pRebar = nullptr;
REBARBANDINFO _rbBand; REBARBANDINFO _rbBand = { 0 };
std::vector<iconLocator> _customIconVect; std::vector<iconLocator> _customIconVect;
TiXmlNode *_toolIcons = nullptr; TiXmlNode *_toolIcons = nullptr;

View File

@ -23,26 +23,21 @@
class ToolTip : public Window class ToolTip : public Window
{ {
public : public:
ToolTip() = default; ToolTip() = default;
void destroy(){ void destroy() {
::DestroyWindow(_hSelf); ::DestroyWindow(_hSelf);
_hSelf = NULL; _hSelf = NULL;
}; };
// Attributes
public:
// Implementation
public:
virtual void init(HINSTANCE hInst, HWND hParent); virtual void init(HINSTANCE hInst, HWND hParent);
void Show(RECT rectTitle, const TCHAR* pszTitleText, int iXOff = 0, int iWidthOff = 0); void Show(RECT rectTitle, const TCHAR* pszTitleText, int iXOff = 0, int iWidthOff = 0);
protected: protected:
WNDPROC _defaultProc = nullptr; WNDPROC _defaultProc = nullptr;
BOOL _bTrackMouse = FALSE; BOOL _bTrackMouse = FALSE;
TOOLINFO _ti; TOOLINFO _ti = { 0 };
static LRESULT CALLBACK staticWinProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { static LRESULT CALLBACK staticWinProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
return (((ToolTip *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA)))->runProc(Message, wParam, lParam)); return (((ToolTip *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA)))->runProc(Message, wParam, lParam));

View File

@ -302,9 +302,9 @@ void VerticalFileSwitcher::initPopupMenus()
::InsertMenu(_hGlobalMenu, 0, MF_BYCOMMAND, CLMNPATH_ID, pathStr.c_str()); ::InsertMenu(_hGlobalMenu, 0, MF_BYCOMMAND, CLMNPATH_ID, pathStr.c_str());
bool isExtColumn = nppGUI._fileSwitcherWithoutExtColumn; bool isExtColumn = nppGUI._fileSwitcherWithoutExtColumn;
::CheckMenuItem(_hGlobalMenu, CLMNEXT_ID, MF_BYCOMMAND | isExtColumn ? MF_UNCHECKED : MF_CHECKED); ::CheckMenuItem(_hGlobalMenu, CLMNEXT_ID, MF_BYCOMMAND | (isExtColumn ? MF_UNCHECKED : MF_CHECKED));
bool isPathColumn = nppGUI._fileSwitcherWithoutPathColumn; bool isPathColumn = nppGUI._fileSwitcherWithoutPathColumn;
::CheckMenuItem(_hGlobalMenu, CLMNPATH_ID, MF_BYCOMMAND | isPathColumn ? MF_UNCHECKED : MF_CHECKED); ::CheckMenuItem(_hGlobalMenu, CLMNPATH_ID, MF_BYCOMMAND | (isPathColumn ? MF_UNCHECKED : MF_CHECKED));
} }
void VerticalFileSwitcher::popupMenuCmd(int cmdID) void VerticalFileSwitcher::popupMenuCmd(int cmdID)
@ -323,7 +323,7 @@ void VerticalFileSwitcher::popupMenuCmd(int cmdID)
{ {
bool& isPathColumn = NppParameters::getInstance().getNppGUI()._fileSwitcherWithoutPathColumn; bool& isPathColumn = NppParameters::getInstance().getNppGUI()._fileSwitcherWithoutPathColumn;
isPathColumn = !isPathColumn; isPathColumn = !isPathColumn;
::CheckMenuItem(_hGlobalMenu, CLMNPATH_ID, MF_BYCOMMAND | isPathColumn ? MF_UNCHECKED : MF_CHECKED); ::CheckMenuItem(_hGlobalMenu, CLMNPATH_ID, MF_BYCOMMAND | (isPathColumn ? MF_UNCHECKED : MF_CHECKED));
reload(); reload();
} }
break; break;

View File

@ -51,10 +51,10 @@ typedef enum {
struct SMModel struct SMModel
{ {
nsPkgInt classTable; nsPkgInt classTable;
PRUint32 classFactor; PRUint32 classFactor = 0;
nsPkgInt stateTable; nsPkgInt stateTable;
const PRUint32* charLenTable; const PRUint32* charLenTable = nullptr;
const char* name; const char* name = nullptr;
SMModel(){}; SMModel(){};
SMModel(nsPkgInt a,PRUint32 b,nsPkgInt c,const PRUint32* d, const char* e): SMModel(nsPkgInt a,PRUint32 b,nsPkgInt c,const PRUint32* d, const char* e):
classTable(a), classFactor(b), stateTable(c), charLenTable(d), name(e){}; classTable(a), classFactor(b), stateTable(c), charLenTable(d), name(e){};
@ -63,7 +63,7 @@ struct SMModel
class nsCodingStateMachine { class nsCodingStateMachine {
public: public:
nsCodingStateMachine(const SMModel* sm) : mModel(sm) { mCurrentState = eStart; } nsCodingStateMachine(const SMModel* sm) : mModel(sm) { mCurrentState = eStart; }
nsSMState NextState(char c){ nsSMState NextState(char c) {
//for each byte we get its class , if it is first byte, we also get byte length //for each byte we get its class , if it is first byte, we also get byte length
PRUint32 byteCls = GETCLASS(c); PRUint32 byteCls = GETCLASS(c);
if (mCurrentState == eStart) if (mCurrentState == eStart)
@ -82,11 +82,11 @@ public:
const char * GetCodingStateMachine() {return mModel->name;} const char * GetCodingStateMachine() {return mModel->name;}
protected: protected:
nsSMState mCurrentState; nsSMState mCurrentState = eStart;
PRUint32 mCurrentCharLen; PRUint32 mCurrentCharLen = 0;
PRUint32 mCurrentBytePos; PRUint32 mCurrentBytePos = 0;
const SMModel *mModel; const SMModel* mModel = nullptr;
}; };
extern const SMModel UTF8SMModel; extern const SMModel UTF8SMModel;

View File

@ -66,7 +66,7 @@ struct SequenceModel
class nsSingleByteCharSetProber : public nsCharSetProber{ class nsSingleByteCharSetProber : public nsCharSetProber{
public: public:
nsSingleByteCharSetProber(const SequenceModel *model) nsSingleByteCharSetProber(const SequenceModel *model)
:mModel(model), mReversed(PR_FALSE), mNameProber(0) { Reset(); } :mModel(model), mReversed(PR_FALSE) { Reset(); }
nsSingleByteCharSetProber(const SequenceModel *model, PRBool reversed, nsCharSetProber* nameProber) nsSingleByteCharSetProber(const SequenceModel *model, PRBool reversed, nsCharSetProber* nameProber)
:mModel(model), mReversed(reversed), mNameProber(nameProber) { Reset(); } :mModel(model), mReversed(reversed), mNameProber(nameProber) { Reset(); }
nsSingleByteCharSetProber(): mModel(0), mReversed(0){}; nsSingleByteCharSetProber(): mModel(0), mReversed(0){};
@ -91,22 +91,22 @@ public:
#endif #endif
protected: protected:
nsProbingState mState; nsProbingState mState = eDetecting;
const SequenceModel* const mModel; const SequenceModel* const mModel = nullptr;
const PRBool mReversed; // PR_TRUE if we need to reverse every pair in the model lookup const PRBool mReversed = PR_FALSE; // PR_TRUE if we need to reverse every pair in the model lookup
//char order of last character //char order of last character
unsigned char mLastOrder; unsigned char mLastOrder = 0;
PRUint32 mTotalSeqs; PRUint32 mTotalSeqs = 0;
PRUint32 mSeqCounters[NUMBER_OF_SEQ_CAT]; PRUint32 mSeqCounters[NUMBER_OF_SEQ_CAT] = { 0 };
PRUint32 mTotalChar; PRUint32 mTotalChar = 0;
//characters that fall in our sampling range //characters that fall in our sampling range
PRUint32 mFreqChar; PRUint32 mFreqChar = 0;
// Optional auxiliary prober for name decision. created and destroyed by the GroupProber // Optional auxiliary prober for name decision. created and destroyed by the GroupProber
nsCharSetProber* mNameProber; nsCharSetProber* mNameProber = nullptr;
}; };