Hi KiCad-devs & Seth,

I was looking at the code for handling spice fields and I noticed
something that I either don't understand or is unnecessary. In this
commit:

https://github.com/KiCad/kicad-source-mirror/commit/170ff66cbbd4f17ebf6fddf24efa7b4d227c15a1

there was a change added in dialog_spice_model.cpp:241-246, which is
present in current master branch. This is how it looks right now:

    // Apply the settings
    for( int i = 0; i < SF_END; ++i )
    {
        if( m_fieldsTmp.count( (SPICE_FIELD) i ) > 0 && !m_fieldsTmp.at( i 
).IsEmpty() )
        {
            if( m_useSchFields )
                getSchField( i ).SetText( m_fieldsTmp[i] );
            else
                getLibField( i ).SetText( m_fieldsTmp[i] );
        }
        else
        {
            // Erase empty fields (having empty fields causes a warning in the 
properties dialog)
            const wxString& spiceField = 
NETLIST_EXPORTER_PSPICE::GetSpiceFieldName( (SPICE_FIELD) i );

            if( m_useSchFields )
                m_schfields->erase( std::remove_if( m_schfields->begin(), 
m_schfields->end(),
                        [&]( const SCH_FIELD& f ) { return f.GetName() == 
spiceField; } ), m_schfields->end() );
            else
                m_libfields->erase( std::remove_if( m_libfields->begin(), 
m_libfields->end(),
                        [&]( const LIB_FIELD& f ) { return f.GetName() == 
spiceField; } ), m_libfields->end() );
        }
    }

In this loop we iterate over all available SPICE fields while m_fieldsTmp 
contain new values to be stored. 
If m_fieldsTmp is non-empty, we add a new value to the field. If it's empty, we 
will delete this field. 

My question is, why deletion is repeated: at first there is called remove_if(), 
and later erase(), which will delete
all the fields behind the removed one. From my point of view it looks like 
remove_if() only should be enough. 

Best regards,
Sylwester

_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to