Cleanup variable naming

Also remove ancient/unused code for lazy resolving
This commit is contained in:
Seth Hillbrand 2023-01-22 15:30:17 -08:00
parent a9ed47f06c
commit efe12f2da5
6 changed files with 78 additions and 98 deletions

View File

@ -218,11 +218,11 @@ void FP_LIB_TABLE::Parse( LIB_TABLE_LEXER* in )
bool FP_LIB_TABLE::operator==( const FP_LIB_TABLE& aFpTable ) const
{
if( rows.size() == aFpTable.rows.size() )
if( m_rows.size() == aFpTable.m_rows.size() )
{
for( unsigned i = 0; i < rows.size(); ++i )
for( unsigned i = 0; i < m_rows.size(); ++i )
{
if( (FP_LIB_TABLE_ROW&)rows[i] != (FP_LIB_TABLE_ROW&)aFpTable.rows[i] )
if( (FP_LIB_TABLE_ROW&)m_rows[i] != (FP_LIB_TABLE_ROW&)aFpTable.m_rows[i] )
return false;
}
@ -237,7 +237,7 @@ void FP_LIB_TABLE::Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) const
{
aOutput->Print( aIndentLevel, "(fp_lib_table\n" );
for( LIB_TABLE_ROWS_CITER it = rows.begin(); it != rows.end(); ++it )
for( LIB_TABLE_ROWS_CITER it = m_rows.begin(); it != m_rows.end(); ++it )
it->Format( aOutput, aIndentLevel+1 );
aOutput->Print( aIndentLevel, ")\n" );

View File

@ -54,10 +54,6 @@ void LIB_TABLE_ROW::setProperties( STRING_UTF8_MAP* aProperties )
void LIB_TABLE_ROW::SetFullURI( const wxString& aFullURI )
{
uri_user = aFullURI;
#if !FP_LATE_ENVVAR
uri_expanded = FP_LIB_TABLE::ExpandSubstitutions( aFullURI );
#endif
}
@ -65,12 +61,7 @@ const wxString LIB_TABLE_ROW::GetFullURI( bool aSubstituted ) const
{
if( aSubstituted )
{
#if !FP_LATE_ENVVAR // early expansion
return uri_expanded;
#else // late expansion
return ExpandEnvVarSubstitutions( uri_user, nullptr );
#endif
}
return uri_user;
@ -123,7 +114,7 @@ void LIB_TABLE_ROW::SetOptions( const wxString& aOptions )
LIB_TABLE::LIB_TABLE( LIB_TABLE* aFallBackTable ) :
fallBack( aFallBackTable )
m_fallBack( aFallBackTable )
{
// not copying fall back, simply search aFallBackTable separately
// if "nickName not found".
@ -138,10 +129,10 @@ LIB_TABLE::~LIB_TABLE()
bool LIB_TABLE::IsEmpty( bool aIncludeFallback )
{
if( !aIncludeFallback || !fallBack )
return rows.empty();
if( !aIncludeFallback || !m_fallBack )
return m_rows.empty();
return rows.empty() && fallBack->IsEmpty( true );
return m_rows.empty() && m_fallBack->IsEmpty( true );
}
@ -170,7 +161,7 @@ bool LIB_TABLE::HasLibrary( const wxString& aNickname, bool aCheckEnabled ) cons
bool LIB_TABLE::HasLibraryWithPath( const wxString& aPath ) const
{
for( const LIB_TABLE_ROW& row : rows )
for( const LIB_TABLE_ROW& row : m_rows )
{
if( row.GetFullURI() == aPath )
return true;
@ -202,11 +193,11 @@ LIB_TABLE_ROW* LIB_TABLE::findRow( const wxString& aNickName, bool aCheckIfEnabl
{
cur->ensureIndex();
for( const std::pair<const wxString, int>& entry : cur->nickIndex )
for( const std::pair<const wxString, int>& entry : cur->m_nickIndex )
{
if( entry.first == aNickName )
{
row = &cur->rows[entry.second];
row = &cur->m_rows[entry.second];
if( !aCheckIfEnabled || row->GetIsEnabled() )
return row;
@ -215,14 +206,14 @@ LIB_TABLE_ROW* LIB_TABLE::findRow( const wxString& aNickName, bool aCheckIfEnabl
// Repeat, this time looking for names that were "fixed" by legacy versions because
// the old eeschema file format didn't support spaces in tokens.
for( const std::pair<const wxString, int>& entry : cur->nickIndex )
for( const std::pair<const wxString, int>& entry : cur->m_nickIndex )
{
wxString legacyLibName = entry.first;
legacyLibName.Replace( " ", "_" );
if( legacyLibName == aNickName )
{
row = &cur->rows[entry.second];
row = &cur->m_rows[entry.second];
if( !aCheckIfEnabled || row->GetIsEnabled() )
return row;
@ -230,7 +221,7 @@ LIB_TABLE_ROW* LIB_TABLE::findRow( const wxString& aNickName, bool aCheckIfEnabl
}
// not found, search fall back table(s), if any
} while( ( cur = cur->fallBack ) != nullptr );
} while( ( cur = cur->m_fallBack ) != nullptr );
return nullptr; // not found
}
@ -244,14 +235,14 @@ const LIB_TABLE_ROW* LIB_TABLE::FindRowByURI( const wxString& aURI )
{
cur->ensureIndex();
for( unsigned i = 0; i < cur->rows.size(); i++ )
for( unsigned i = 0; i < cur->m_rows.size(); i++ )
{
wxString tmp = cur->rows[i].GetFullURI( true );
wxString tmp = cur->m_rows[i].GetFullURI( true );
if( tmp.Find( "://" ) != wxNOT_FOUND )
{
if( tmp == aURI )
return &cur->rows[i]; // found as URI
return &cur->m_rows[i]; // found as URI
}
else
{
@ -261,12 +252,12 @@ const LIB_TABLE_ROW* LIB_TABLE::FindRowByURI( const wxString& aURI )
// a symlink to the same real file, the comparison will be true. See
// wxFileName::SameAs() in the wxWidgets source.
if( fn == wxFileName( tmp ) )
return &cur->rows[i]; // found as full path and file name
return &cur->m_rows[i]; // found as full path and file name
}
}
// not found, search fall back table(s), if any
} while( ( cur = cur->fallBack ) != nullptr );
} while( ( cur = cur->m_fallBack ) != nullptr );
return nullptr; // not found
}
@ -283,13 +274,13 @@ std::vector<wxString> LIB_TABLE::GetLogicalLibs()
do
{
for( LIB_TABLE_ROWS_CITER it = cur->rows.begin(); it!=cur->rows.end(); ++it )
for( LIB_TABLE_ROWS_CITER it = cur->m_rows.begin(); it!=cur->m_rows.end(); ++it )
{
if( it->GetIsEnabled() )
unique.insert( it->GetNickName() );
}
} while( ( cur = cur->fallBack ) != nullptr );
} while( ( cur = cur->m_fallBack ) != nullptr );
ret.reserve( unique.size() );
@ -314,20 +305,20 @@ bool LIB_TABLE::InsertRow( LIB_TABLE_ROW* aRow, bool doReplace )
std::lock_guard<std::mutex> lock( m_nickIndexMutex );
INDEX_CITER it = nickIndex.find( aRow->GetNickName() );
INDEX_CITER it = m_nickIndex.find( aRow->GetNickName() );
aRow->SetParent( this );
if( it == nickIndex.end() )
if( it == m_nickIndex.end() )
{
rows.push_back( aRow );
nickIndex.insert( INDEX_VALUE( aRow->GetNickName(), rows.size() - 1 ) );
m_rows.push_back( aRow );
m_nickIndex.insert( INDEX_VALUE( aRow->GetNickName(), m_rows.size() - 1 ) );
return true;
}
if( doReplace )
{
rows.replace( it->second, aRow );
m_rows.replace( it->second, aRow );
return true;
}

View File

@ -83,27 +83,27 @@ class SYMBOL_LIB_TABLE_GRID : public LIB_TABLE_GRID, public SYMBOL_LIB_TABLE
friend class SYMBOL_GRID_TRICKS;
protected:
LIB_TABLE_ROW* at( size_t aIndex ) override { return &rows.at( aIndex ); }
LIB_TABLE_ROW* at( size_t aIndex ) override { return &m_rows.at( aIndex ); }
size_t size() const override { return rows.size(); }
size_t size() const override { return m_rows.size(); }
LIB_TABLE_ROW* makeNewRow() override
{
return dynamic_cast< LIB_TABLE_ROW* >( new SYMBOL_LIB_TABLE_ROW );
}
LIB_TABLE_ROWS_ITER begin() override { return rows.begin(); }
LIB_TABLE_ROWS_ITER begin() override { return m_rows.begin(); }
LIB_TABLE_ROWS_ITER insert( LIB_TABLE_ROWS_ITER aIterator, LIB_TABLE_ROW* aRow ) override
{
return rows.insert( aIterator, aRow );
return m_rows.insert( aIterator, aRow );
}
void push_back( LIB_TABLE_ROW* aRow ) override { rows.push_back( aRow ); }
void push_back( LIB_TABLE_ROW* aRow ) override { m_rows.push_back( aRow ); }
LIB_TABLE_ROWS_ITER erase( LIB_TABLE_ROWS_ITER aFirst, LIB_TABLE_ROWS_ITER aLast ) override
{
return rows.erase( aFirst, aLast );
return m_rows.erase( aFirst, aLast );
}
public:
@ -130,7 +130,7 @@ public:
SYMBOL_LIB_TABLE_GRID( const SYMBOL_LIB_TABLE& aTableToEdit )
{
rows = aTableToEdit.rows;
m_rows = aTableToEdit.m_rows;
}
};
@ -180,7 +180,7 @@ protected:
tbl->AppendRows( tmp_tbl.GetCount() - tbl->GetNumberRows() );
for( unsigned i = 0; i < tmp_tbl.GetCount(); ++i )
tbl->rows.replace( i, tmp_tbl.At( i ).clone() );
tbl->m_rows.replace( i, tmp_tbl.At( i ).clone() );
}
m_grid->AutoSizeColumns( false );
@ -668,10 +668,10 @@ void PANEL_SYM_LIB_TABLE::moveUpHandler( wxCommandEvent& event )
if( curRow >= 1 )
{
boost::ptr_vector< LIB_TABLE_ROW >::auto_type move_me =
tbl->rows.release( tbl->rows.begin() + curRow );
tbl->m_rows.release( tbl->m_rows.begin() + curRow );
--curRow;
tbl->rows.insert( tbl->rows.begin() + curRow, move_me.release() );
tbl->m_rows.insert( tbl->m_rows.begin() + curRow, move_me.release() );
if( tbl->GetView() )
{
@ -695,13 +695,13 @@ void PANEL_SYM_LIB_TABLE::moveDownHandler( wxCommandEvent& event )
int curRow = m_cur_grid->GetGridCursorRow();
// @todo: add multiple selection moves.
if( unsigned( curRow + 1 ) < tbl->rows.size() )
if( unsigned( curRow + 1 ) < tbl->m_rows.size() )
{
boost::ptr_vector< LIB_TABLE_ROW >::auto_type move_me =
tbl->rows.release( tbl->rows.begin() + curRow );
tbl->m_rows.release( tbl->m_rows.begin() + curRow );
++curRow;
tbl->rows.insert( tbl->rows.begin() + curRow, move_me.release() );
tbl->m_rows.insert( tbl->m_rows.begin() + curRow, move_me.release() );
if( tbl->GetView() )
{
@ -889,8 +889,8 @@ bool PANEL_SYM_LIB_TABLE::TransferDataFromWindow()
m_parent->m_GlobalTableChanged = true;
m_globalTable->Clear();
m_globalTable->rows.transfer( m_globalTable->rows.end(), global_model()->rows.begin(),
global_model()->rows.end(), global_model()->rows );
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();
}
@ -899,8 +899,8 @@ bool PANEL_SYM_LIB_TABLE::TransferDataFromWindow()
m_parent->m_ProjectTableChanged = true;
m_projectTable->Clear();
m_projectTable->rows.transfer( m_projectTable->rows.end(), project_model()->rows.begin(),
project_model()->rows.end(), project_model()->rows );
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();
}

View File

@ -270,7 +270,7 @@ void SYMBOL_LIB_TABLE::Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) cons
{
aOutput->Print( aIndentLevel, "(sym_lib_table\n" );
for( LIB_TABLE_ROWS_CITER it = rows.begin(); it != rows.end(); ++it )
for( LIB_TABLE_ROWS_CITER it = m_rows.begin(); it != m_rows.end(); ++it )
{
it->Format( aOutput, aIndentLevel+1 );
}

View File

@ -35,9 +35,6 @@
#include <string_utf8_map.h>
#include <richio.h>
#define FP_LATE_ENVVAR 1 ///< late=1/early=0 environment variable expansion
class OUTPUTFORMATTER;
class LIB_TABLE_LEXER;
class LIB_ID;
@ -207,9 +204,6 @@ protected:
LIB_TABLE_ROW( const LIB_TABLE_ROW& aRow ) :
nickName( aRow.nickName ),
uri_user( aRow.uri_user ),
#if !FP_LATE_ENVVAR
uri_expanded( aRow.uri_expanded ),
#endif
options( aRow.options ),
description( aRow.description ),
enabled( aRow.enabled ),
@ -232,11 +226,6 @@ private:
wxString nickName;
wxString uri_user; ///< what user entered from UI or loaded from disk
#if !FP_LATE_ENVVAR
wxString uri_expanded; ///< from ExpandSubstitutions()
#endif
wxString options;
wxString description;
@ -342,8 +331,8 @@ public:
{
std::lock_guard<std::mutex> lock( m_nickIndexMutex );
rows.clear();
nickIndex.clear();
m_rows.clear();
m_nickIndex.clear();
}
/**
@ -354,14 +343,14 @@ public:
*/
bool operator==( const LIB_TABLE& r ) const
{
if( rows.size() == r.rows.size() )
if( m_rows.size() == r.m_rows.size() )
{
unsigned i;
for( i = 0; i < rows.size() && rows[i] == r.rows[i]; ++i )
for( i = 0; i < m_rows.size() && m_rows[i] == r.m_rows[i]; ++i )
;
if( i == rows.size() )
if( i == m_rows.size() )
return true;
}
@ -375,7 +364,7 @@ public:
*/
unsigned GetCount() const
{
return rows.size();
return m_rows.size();
}
/**
@ -385,7 +374,7 @@ public:
*/
LIB_TABLE_ROW& At( unsigned aIndex )
{
return rows[aIndex];
return m_rows[aIndex];
}
/**
@ -393,7 +382,7 @@ public:
*/
const LIB_TABLE_ROW& At( unsigned aIndex ) const
{
return rows[aIndex];
return m_rows[aIndex];
}
/**
@ -460,11 +449,11 @@ public:
*/
bool RemoveRow( const LIB_TABLE_ROW* aRow )
{
for( auto iter = rows.begin(); iter != rows.end(); ++iter )
for( auto iter = m_rows.begin(); iter != m_rows.end(); ++iter )
{
if( *iter == *aRow )
{
rows.erase( iter, iter + 1 );
m_rows.erase( iter, iter + 1 );
reindex();
return true;
}
@ -536,10 +525,10 @@ protected:
{
std::lock_guard<std::mutex> lock( m_nickIndexMutex );
nickIndex.clear();
m_nickIndex.clear();
for( LIB_TABLE_ROWS_ITER it = rows.begin(); it != rows.end(); ++it )
nickIndex.insert( INDEX_VALUE( it->GetNickName(), it - rows.begin() ) );
for( LIB_TABLE_ROWS_ITER it = m_rows.begin(); it != m_rows.end(); ++it )
m_nickIndex.insert( INDEX_VALUE( it->GetNickName(), it - m_rows.begin() ) );
}
void ensureIndex()
@ -547,7 +536,7 @@ protected:
// The dialog lib table editor may not maintain the nickIndex.
// Lazy indexing may be required. To handle lazy indexing, we must enforce
// that "nickIndex" is either empty or accurate, but never inaccurate.
if( !nickIndex.size() )
if( !m_nickIndex.size() )
reindex();
}
@ -556,7 +545,7 @@ private:
friend class LIB_TABLE_GRID;
protected:
LIB_TABLE_ROWS rows;
LIB_TABLE_ROWS m_rows;
/// this is a non-owning index into the LIB_TABLE_ROWS table
typedef std::map<wxString,int> INDEX; // "int" is std::vector array index
@ -565,9 +554,9 @@ protected:
typedef INDEX::value_type INDEX_VALUE;
/// this particular key is the nickName within each row.
INDEX nickIndex;
INDEX m_nickIndex;
LIB_TABLE* fallBack;
LIB_TABLE* m_fallBack;
/// Mutex to protect access to the nickIndex variable
mutable std::mutex m_nickIndexMutex;

View File

@ -212,34 +212,34 @@ class FP_LIB_TABLE_GRID : public LIB_TABLE_GRID, public FP_LIB_TABLE
friend class FP_GRID_TRICKS;
protected:
LIB_TABLE_ROW* at( size_t aIndex ) override { return &rows.at( aIndex ); }
LIB_TABLE_ROW* at( size_t aIndex ) override { return &m_rows.at( aIndex ); }
size_t size() const override { return rows.size(); }
size_t size() const override { return m_rows.size(); }
LIB_TABLE_ROW* makeNewRow() override
{
return dynamic_cast< LIB_TABLE_ROW* >( new FP_LIB_TABLE_ROW );
}
LIB_TABLE_ROWS_ITER begin() override { return rows.begin(); }
LIB_TABLE_ROWS_ITER begin() override { return m_rows.begin(); }
LIB_TABLE_ROWS_ITER insert( LIB_TABLE_ROWS_ITER aIterator, LIB_TABLE_ROW* aRow ) override
{
return rows.insert( aIterator, aRow );
return m_rows.insert( aIterator, aRow );
}
void push_back( LIB_TABLE_ROW* aRow ) override { rows.push_back( aRow ); }
void push_back( LIB_TABLE_ROW* aRow ) override { m_rows.push_back( aRow ); }
LIB_TABLE_ROWS_ITER erase( LIB_TABLE_ROWS_ITER aFirst, LIB_TABLE_ROWS_ITER aLast ) override
{
return rows.erase( aFirst, aLast );
return m_rows.erase( aFirst, aLast );
}
public:
FP_LIB_TABLE_GRID( const FP_LIB_TABLE& aTableToEdit )
{
rows = aTableToEdit.rows;
m_rows = aTableToEdit.m_rows;
}
};
@ -342,7 +342,7 @@ protected:
tbl->AppendRows( tmp_tbl.GetCount() - tbl->GetNumberRows() );
for( unsigned i = 0; i < tmp_tbl.GetCount(); ++i )
tbl->rows.replace( i, tmp_tbl.At( i ).clone() );
tbl->m_rows.replace( i, tmp_tbl.At( i ).clone() );
}
m_grid->AutoSizeColumns( false );
@ -723,10 +723,10 @@ void PANEL_FP_LIB_TABLE::moveUpHandler( wxCommandEvent& event )
if( curRow >= 1 )
{
boost::ptr_vector< LIB_TABLE_ROW >::auto_type move_me =
tbl->rows.release( tbl->rows.begin() + curRow );
tbl->m_rows.release( tbl->m_rows.begin() + curRow );
--curRow;
tbl->rows.insert( tbl->rows.begin() + curRow, move_me.release() );
tbl->m_rows.insert( tbl->m_rows.begin() + curRow, move_me.release() );
if( tbl->GetView() )
{
@ -750,13 +750,13 @@ void PANEL_FP_LIB_TABLE::moveDownHandler( wxCommandEvent& event )
int curRow = m_cur_grid->GetGridCursorRow();
// @todo: add multiple selection moves.
if( unsigned( curRow + 1 ) < tbl->rows.size() )
if( unsigned( curRow + 1 ) < tbl->m_rows.size() )
{
boost::ptr_vector< LIB_TABLE_ROW >::auto_type move_me =
tbl->rows.release( tbl->rows.begin() + curRow );
tbl->m_rows.release( tbl->m_rows.begin() + curRow );
++curRow;
tbl->rows.insert( tbl->rows.begin() + curRow, move_me.release() );
tbl->m_rows.insert( tbl->m_rows.begin() + curRow, move_me.release() );
if( tbl->GetView() )
{
@ -983,8 +983,8 @@ bool PANEL_FP_LIB_TABLE::TransferDataFromWindow()
m_parent->m_GlobalTableChanged = true;
m_global->Clear();
m_global->rows.transfer( m_global->rows.end(), global_model()->rows.begin(),
global_model()->rows.end(), global_model()->rows );
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();
}
@ -993,8 +993,8 @@ bool PANEL_FP_LIB_TABLE::TransferDataFromWindow()
m_parent->m_ProjectTableChanged = true;
m_project->Clear();
m_project->rows.transfer( m_project->rows.end(), project_model()->rows.begin(),
project_model()->rows.end(), project_model()->rows );
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();
}