Fix the shared_lock added and micro-opt the reindex
This commit is contained in:
parent
facd50f4fd
commit
dffd2da8c8
|
@ -193,7 +193,7 @@ LIB_TABLE_ROW* LIB_TABLE::findRow( const wxString& aNickName, bool aCheckIfEnabl
|
|||
{
|
||||
cur->ensureIndex();
|
||||
|
||||
std::shared_lock<std::shared_mutex> lock( m_nickIndexMutex );
|
||||
std::shared_lock<std::shared_mutex> lock( cur->m_nickIndexMutex );
|
||||
|
||||
for( const std::pair<const wxString, int>& entry : cur->m_nickIndex )
|
||||
{
|
||||
|
|
|
@ -891,7 +891,7 @@ bool PANEL_SYM_LIB_TABLE::TransferDataFromWindow()
|
|||
m_globalTable->Clear();
|
||||
m_globalTable->m_rows.transfer( m_globalTable->m_rows.end(), global_model()->m_rows.begin(),
|
||||
global_model()->m_rows.end(), global_model()->m_rows );
|
||||
m_globalTable->reindex();
|
||||
m_globalTable->reindex( true );
|
||||
}
|
||||
|
||||
if( project_model() && *project_model() != *m_projectTable )
|
||||
|
@ -901,7 +901,7 @@ bool PANEL_SYM_LIB_TABLE::TransferDataFromWindow()
|
|||
m_projectTable->Clear();
|
||||
m_projectTable->m_rows.transfer( m_projectTable->m_rows.end(), project_model()->m_rows.begin(),
|
||||
project_model()->m_rows.end(), project_model()->m_rows );
|
||||
m_projectTable->reindex();
|
||||
m_projectTable->reindex( true );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -454,7 +454,7 @@ public:
|
|||
if( *iter == *aRow )
|
||||
{
|
||||
m_rows.erase( iter, iter + 1 );
|
||||
reindex();
|
||||
reindex( true );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -539,10 +539,22 @@ protected:
|
|||
*/
|
||||
bool migrate();
|
||||
|
||||
void reindex()
|
||||
/**
|
||||
* Rebuilds the m_nickIndex
|
||||
*
|
||||
* @param aForce is to avoid rebuilding the index multiple times because multiple threads hit ensureIndex
|
||||
* at the same time
|
||||
*/
|
||||
void reindex( bool aForce )
|
||||
{
|
||||
std::lock_guard<std::shared_mutex> lock( m_nickIndexMutex );
|
||||
|
||||
if( !aForce )
|
||||
{
|
||||
if( m_nickIndex.size() )
|
||||
return;
|
||||
}
|
||||
|
||||
m_nickIndex.clear();
|
||||
|
||||
for( LIB_TABLE_ROWS_ITER it = m_rows.begin(); it != m_rows.end(); ++it )
|
||||
|
@ -555,7 +567,7 @@ protected:
|
|||
// Lazy indexing may be required. To handle lazy indexing, we must enforce
|
||||
// that "nickIndex" is either empty or accurate, but never inaccurate.
|
||||
if( !m_nickIndex.size() )
|
||||
reindex();
|
||||
reindex( false );
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -989,7 +989,7 @@ bool PANEL_FP_LIB_TABLE::TransferDataFromWindow()
|
|||
m_global->Clear();
|
||||
m_global->m_rows.transfer( m_global->m_rows.end(), global_model()->m_rows.begin(),
|
||||
global_model()->m_rows.end(), global_model()->m_rows );
|
||||
m_global->reindex();
|
||||
m_global->reindex( true );
|
||||
}
|
||||
|
||||
if( project_model() && *project_model() != *m_project )
|
||||
|
@ -999,7 +999,7 @@ bool PANEL_FP_LIB_TABLE::TransferDataFromWindow()
|
|||
m_project->Clear();
|
||||
m_project->m_rows.transfer( m_project->m_rows.end(), project_model()->m_rows.begin(),
|
||||
project_model()->m_rows.end(), project_model()->m_rows );
|
||||
m_project->reindex();
|
||||
m_project->reindex( true );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue