From 3d4a47a6bbb1535c35319ac0f45c95b5a5057b59 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 14:56:36 +0100 Subject: [PATCH] Change RowToTreeNodeJob::m_row type to int and make it const It doesn't make much sense to use an "unsigned int" variable only to cast it to int everywhere where it's used. Just make it "int" from the get go and have a single cast to int in the caller. Also make m_row const as it never changes. --- src/generic/datavgen.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 1ad0120fb3..5965dae3ec 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3468,7 +3468,7 @@ int wxDataViewMainWindow::GetLineHeight( unsigned int row ) const class RowToTreeNodeJob: public DoJob { public: - RowToTreeNodeJob(unsigned int row, int current, wxDataViewTreeNode *parent) + RowToTreeNodeJob(int row, int current, wxDataViewTreeNode *parent) : m_row(row), m_current(current), m_parent(parent), m_ret(NULL) { } @@ -3476,13 +3476,13 @@ public: virtual int operator() ( wxDataViewTreeNode * node ) wxOVERRIDE { m_current ++; - if( m_current == static_cast(m_row)) + if( m_current == m_row) { m_ret = node; return DoJob::DONE; } - if( node->GetSubTreeCount() + m_current < static_cast(m_row) ) + if( node->GetSubTreeCount() + m_current < m_row ) { m_current += node->GetSubTreeCount(); return DoJob::SKIP_SUBTREE; @@ -3497,7 +3497,7 @@ public: if ( node->HasChildren() && (int)node->GetChildNodes().size() == node->GetSubTreeCount() ) { - const int index = static_cast(m_row) - m_current - 1; + const int index = m_row - m_current - 1; m_ret = node->GetChildNodes()[index]; return DoJob::DONE; } @@ -3510,7 +3510,7 @@ public: { return m_ret; } private: - unsigned int m_row; + const int m_row; int m_current; wxDataViewTreeNode* m_parent; wxDataViewTreeNode* m_ret; @@ -3523,7 +3523,7 @@ wxDataViewTreeNode * wxDataViewMainWindow::GetTreeNodeByRow(unsigned int row) co if ( row == (unsigned)-1 ) return NULL; - RowToTreeNodeJob job( row , -2, m_root ); + RowToTreeNodeJob job( static_cast(row) , -2, m_root ); Walker( m_root , job ); return job.GetResult(); }