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
{
private:
intptr_t _maxPeekLenInKB = 512; // 512 KB
public:
intptr_t _firstVisibleDisplayLine = -1;
intptr_t _firstVisibleDocLine = -1; // map
@ -171,9 +174,6 @@ struct MapPosition
bool _isWrap = false;
bool isValid() const { return (_firstVisibleDisplayLine != -1); };
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;
ReBar* _pRebar = nullptr;
REBARBANDINFO _rbBand;
REBARBANDINFO _rbBand = { 0 };
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
void markSelectedTextInc(bool enable, FindOption *opt = NULL);

View File

@ -43,7 +43,7 @@ public :
size_t doPrint(bool justDoIt);
private :
PRINTDLG _pdlg;
PRINTDLG _pdlg = { 0 };
ScintillaEditView *_pSEView = nullptr;
size_t _startPos = 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()
{

View File

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

View File

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

View File

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

View File

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

View File

@ -23,26 +23,21 @@
class ToolTip : public Window
{
public :
public:
ToolTip() = default;
void destroy(){
void destroy() {
::DestroyWindow(_hSelf);
_hSelf = NULL;
};
// Attributes
public:
// Implementation
public:
virtual void init(HINSTANCE hInst, HWND hParent);
void Show(RECT rectTitle, const TCHAR* pszTitleText, int iXOff = 0, int iWidthOff = 0);
protected:
WNDPROC _defaultProc = nullptr;
WNDPROC _defaultProc = nullptr;
BOOL _bTrackMouse = FALSE;
TOOLINFO _ti;
TOOLINFO _ti = { 0 };
static LRESULT CALLBACK staticWinProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM 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());
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;
::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)
@ -323,7 +323,7 @@ void VerticalFileSwitcher::popupMenuCmd(int cmdID)
{
bool& isPathColumn = NppParameters::getInstance().getNppGUI()._fileSwitcherWithoutPathColumn;
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();
}
break;

View File

@ -51,10 +51,10 @@ typedef enum {
struct SMModel
{
nsPkgInt classTable;
PRUint32 classFactor;
PRUint32 classFactor = 0;
nsPkgInt stateTable;
const PRUint32* charLenTable;
const char* name;
const PRUint32* charLenTable = nullptr;
const char* name = nullptr;
SMModel(){};
SMModel(nsPkgInt a,PRUint32 b,nsPkgInt c,const PRUint32* d, const char* e):
classTable(a), classFactor(b), stateTable(c), charLenTable(d), name(e){};
@ -63,7 +63,7 @@ struct SMModel
class nsCodingStateMachine {
public:
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
PRUint32 byteCls = GETCLASS(c);
if (mCurrentState == eStart)
@ -82,11 +82,11 @@ public:
const char * GetCodingStateMachine() {return mModel->name;}
protected:
nsSMState mCurrentState;
PRUint32 mCurrentCharLen;
PRUint32 mCurrentBytePos;
nsSMState mCurrentState = eStart;
PRUint32 mCurrentCharLen = 0;
PRUint32 mCurrentBytePos = 0;
const SMModel *mModel;
const SMModel* mModel = nullptr;
};
extern const SMModel UTF8SMModel;

View File

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