Skip to content
Snippets Groups Projects
Commit 9a380daa authored by Jan Trávníček's avatar Jan Trávníček Committed by Jan Travnicek
Browse files

apply some cppcheck proposed changes

parent 85b58d09
No related branches found
No related tags found
1 merge request!87Merge jt
......@@ -52,11 +52,11 @@ public:
}
 
virtual bool inputsAttached ( ) const override {
for ( const std::pair < std::shared_ptr < OperationAbstraction >, bool > & param : m_params )
if ( ! ( bool ) param.first )
return false;
auto attached_lambda = [ ] ( const std::pair < std::shared_ptr < OperationAbstraction >, bool > & param ) {
return ( bool ) param.first;
};
 
return true;
return std::all_of ( m_params.begin ( ), m_params.end ( ), attached_lambda );
}
 
virtual bool eval ( ) override {
......
......@@ -25,11 +25,15 @@ std::shared_ptr < abstraction::OperationAbstraction > ContainerRegistry::getAbst
if ( group == getEntries ( ).end ( ) )
throw std::invalid_argument ( "Entry " + container + " not available" );
 
for ( const ext::pair < std::string, std::unique_ptr < Entry > > & entry : group->second )
if ( ext::is_same_type ( param, ext::erase_template_info ( entry.first ) ) )
return entry.second->getAbstraction ( );
auto is_same_type_lambda = [ & ] ( const ext::pair < std::string, std::unique_ptr < Entry > > & entry ) {
return ext::is_same_type ( param, ext::erase_template_info ( entry.first ) );
};
auto iter = std::find_if ( group->second.begin ( ), group->second.end ( ), is_same_type_lambda );
if ( iter == group->second.end ( ) )
throw std::invalid_argument ( "Entry for " + container + " parametrized with " + param + " not available." );
 
throw std::invalid_argument ( "Entry for " + container + " parametrized with " + param + " not available." );
return iter->second->getAbstraction ( );
}
 
ext::set < std::string > ContainerRegistry::listOverloads ( const std::string & container ) {
......
......@@ -44,7 +44,7 @@ private:
static ext::map < std::string, ext::list < ext::pair < std::string, std::unique_ptr < Entry > > > > & getEntries ( );
 
public:
static void unregisterSet ( std::string param ) {
static void unregisterSet ( const std::string & param ) {
std::string container = "Set";
 
auto & group = getEntries ( ) [ container ];
......@@ -71,7 +71,7 @@ public:
if ( entry.first == param )
throw std::invalid_argument ( "Callback for " + param + " in contaier " + container + " already registered." );
 
group.insert ( group.end ( ), ext::make_pair ( param, std::make_unique < SetEntryImpl < ParamTypes > > ( ) ) );
group.insert ( group.end ( ), ext::make_pair ( std::move ( param ), std::make_unique < SetEntryImpl < ParamTypes > > ( ) ) );
}
 
template < class ParamTypes >
......
......@@ -109,6 +109,9 @@ public:
* \param other the other instance
*/
ptr_value & operator = ( const ptr_value & other ) {
if ( this == & other )
return *this;
delete m_data;
m_data = ext::clone ( other.m_data );
return * this;
......
......@@ -65,13 +65,15 @@ class ReadlinePromptHistory {
template < class Callable >
static void history_transform ( Callable callable ) {
HIST_ENTRY ** history = history_list ( );
int i = 0;
if ( history ) while ( * history ) {
char * tmp = callable ( ( * history )->line );
replace_history_entry ( i, tmp, ( * history )->data );
free ( tmp );
++ history;
++ i;
if ( history ) {
unsigned i = 0;
while ( * history ) {
char * tmp = callable ( ( * history )->line );
replace_history_entry ( i, tmp, ( * history )->data );
free ( tmp );
++ history;
++ i;
}
}
}
 
......
  • Owner

    code-style otazka - proc ma cenu ukladat si lambda f. do promennych?

  • Author Owner

    Mě se to tak lépe čte. Když je to přímo v tom místě kde se použije tak to často splývá s tím voláním kam se lambda předává. Taky mě napadá že ta proměnná by mohla být static.

    Edited by Jan Trávníček
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment