Skip to content

Commit

Permalink
clang-tidy modernize-use-emplace
Browse files Browse the repository at this point in the history
  • Loading branch information
scamille committed Nov 22, 2019
1 parent 5b8e039 commit 702bbfa
Show file tree
Hide file tree
Showing 27 changed files with 80 additions and 83 deletions.
6 changes: 3 additions & 3 deletions engine/action/sc_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ action_priority_t* action_priority_list_t::add_action( const std::string& action
{
if ( action_priority_str.empty() )
return nullptr;
action_list.push_back( action_priority_t( action_priority_str, comment ) );
action_list.emplace_back( action_priority_str, comment );
return &( action_list.back() );
}

Expand Down Expand Up @@ -884,7 +884,7 @@ bool action_t::verify_actor_weapon() const
{
if ( data().equipped_subclass_mask() & ( 1 << static_cast<unsigned>( wt ) ) )
{
types.push_back( util::weapon_subclass_string( wt ) );
types.emplace_back(util::weapon_subclass_string( wt ) );
}
}
sim->errorf( "Player %s attempting to use action %s without the required main-hand weapon "
Expand All @@ -902,7 +902,7 @@ bool action_t::verify_actor_weapon() const
{
if ( data().equipped_subclass_mask() & ( 1 << static_cast<unsigned>( wt ) ) )
{
types.push_back( util::weapon_subclass_string( wt ) );
types.emplace_back(util::weapon_subclass_string( wt ) );
}
}
sim->errorf( "Player %s attempting to use action %s without the required off-hand weapon "
Expand Down
2 changes: 1 addition & 1 deletion engine/buff/sc_buff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2169,7 +2169,7 @@ stat_buff_t::stat_buff_t( actor_pair_t q, const std::string& name, const spell_d

for ( size_t j = 0; j < k.size(); j++ )
{
stats.push_back( buff_stat_t( k[ j ], amount ) );
stats.emplace_back( k[ j ], amount );
}
}
else if ( effect.subtype() == A_MOD_DAMAGE_DONE && ( effect.misc_value1() & 0x7E ) )
Expand Down
2 changes: 1 addition & 1 deletion engine/class_modules/priest/sc_priest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ priest_td_t::priest_td_t( player_t* target, priest_t& p ) : actor_target_data_t(

buffs.schism = make_buff( *this, "schism", p.talents.schism );

target->callbacks_on_demise.push_back( [this]( player_t* ) { target_demise(); } );
target->callbacks_on_demise.emplace_back([this]( player_t* ) { target_demise(); } );
}

void priest_td_t::reset()
Expand Down
9 changes: 3 additions & 6 deletions engine/class_modules/sc_death_knight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8219,20 +8219,17 @@ void death_knight_t::activate()
{
if ( talent.soul_reaper->ok() )
{
target->callbacks_on_demise.push_back(
[this]( player_t* t ) { trigger_soul_reaper_death( t ); } );
target->callbacks_on_demise.emplace_back([this]( player_t* t ) { trigger_soul_reaper_death( t ); } );
}

if ( spec.festering_wound->ok() )
{
target->callbacks_on_demise.push_back(
[this]( player_t* t ) { trigger_festering_wound_death( t ); } );
target->callbacks_on_demise.emplace_back([this]( player_t* t ) { trigger_festering_wound_death( t ); } );
}

if ( spec.outbreak->ok() )
{
target->callbacks_on_demise.push_back(
[this]( player_t* t ) { trigger_virulent_plague_death( t ); } );
target->callbacks_on_demise.emplace_back([this]( player_t* t ) { trigger_virulent_plague_death( t ); } );
}
}
} );
Expand Down
2 changes: 1 addition & 1 deletion engine/class_modules/sc_demon_hunter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4116,7 +4116,7 @@ demon_hunter_td_t::demon_hunter_td_t( player_t* target, demon_hunter_t& p )
->set_default_value( p.find_spell( 268178 )->effectN( 1 ).percent() );
}

target->callbacks_on_demise.push_back( [this]( player_t* ) { target_demise(); } );
target->callbacks_on_demise.emplace_back([this]( player_t* ) { target_demise(); } );
}

void demon_hunter_td_t::target_demise()
Expand Down
4 changes: 2 additions & 2 deletions engine/class_modules/sc_druid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7424,7 +7424,7 @@ void druid_t::activate()
if ( !target -> is_enemy() )
return;

target->callbacks_on_demise.push_back([this](player_t* target) -> void {
target->callbacks_on_demise.emplace_back([this](player_t* target) -> void {
auto p = this;
if (p -> specialization() != DRUID_FERAL)
return;
Expand All @@ -7445,7 +7445,7 @@ void druid_t::activate()
});


callbacks_on_demise.push_back( [this]( player_t* target ) -> void {
callbacks_on_demise.emplace_back([this]( player_t* target ) -> void {
if (sim->active_player->specialization() != DRUID_FERAL)
return;

Expand Down
4 changes: 2 additions & 2 deletions engine/class_modules/sc_hunter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ struct player_data_t
if ( it != data_.cend() )
return it -> second.get();

data_.push_back( record_t( a -> name_str, std::make_unique<action_data_t>( ) ) );
data_.emplace_back( a -> name_str, std::make_unique<action_data_t>( ) );
return data_.back().second.get();
}

Expand Down Expand Up @@ -4462,7 +4462,7 @@ hunter_td_t::hunter_td_t( player_t* target, hunter_t* p ):
dots.pheromone_bomb = target -> get_dot( "pheromone_bomb", p );
dots.shrapnel_bomb = target -> get_dot( "shrapnel_bomb", p );

target -> callbacks_on_demise.push_back( std::bind( &hunter_td_t::target_demise, this ) );
target -> callbacks_on_demise.emplace_back(std::bind( &hunter_td_t::target_demise, this ) );
}

void hunter_td_t::target_demise()
Expand Down
2 changes: 1 addition & 1 deletion engine/class_modules/sc_rogue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5488,7 +5488,7 @@ rogue_td_t::rogue_td_t( player_t* target, rogue_t* source ) :
// death.
if ( source -> specialization() == ROGUE_ASSASSINATION && source -> spec.venomous_wounds -> ok() )
{
target -> callbacks_on_demise.push_back( std::bind( &rogue_t::trigger_venomous_wounds_death, source, std::placeholders::_1 ) );
target -> callbacks_on_demise.emplace_back(std::bind( &rogue_t::trigger_venomous_wounds_death, source, std::placeholders::_1 ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion engine/class_modules/warlock/sc_warlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ namespace warlock
debuffs_jaws_of_shadow = make_buff( *this, "jaws_of_shadow", source->find_spell( 242922 ) );
debuffs_from_the_shadows = make_buff(*this, "from_the_shadows", source->find_spell(270569));

target->callbacks_on_demise.push_back( [this]( player_t* ) { target_demise(); } );
target->callbacks_on_demise.emplace_back([this]( player_t* ) { target_demise(); } );
}

void warlock_td_t::target_demise()
Expand Down
4 changes: 2 additions & 2 deletions engine/class_modules/warlock/sc_warlock_pets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ warlock_pet_t::warlock_pet_t(warlock_t* owner, const std::string& pet_name, pet_

owner_coeff.health = 0.5;

callbacks_on_arise.push_back( [ owner ]() { owner->active_pets++; } );
callbacks_on_demise.push_back( [ owner ]( const player_t* ) { owner->active_pets--; } );
callbacks_on_arise.emplace_back([ owner ]() { owner->active_pets++; } );
callbacks_on_demise.emplace_back([ owner ]( const player_t* ) { owner->active_pets--; } );
}

warlock_t* warlock_pet_t::o()
Expand Down
6 changes: 3 additions & 3 deletions engine/dbc/sc_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ void dbc_override::register_spell( dbc_t& dbc, unsigned spell_id, const std::str
throw std::invalid_argument(fmt::format("Invalid field '{}'.", field));
}

override_entries_.push_back( dbc_override_entry_t( DBC_OVERRIDE_SPELL, field, spell_id, v ) );
override_entries_.emplace_back( DBC_OVERRIDE_SPELL, field, spell_id, v );
}

void dbc_override::register_effect( dbc_t& dbc, unsigned effect_id, const std::string& field, double v )
Expand All @@ -945,7 +945,7 @@ void dbc_override::register_effect( dbc_t& dbc, unsigned effect_id, const std::s
throw std::invalid_argument(fmt::format("Invalid field '{}'.", field));
}

override_entries_.push_back( dbc_override_entry_t( DBC_OVERRIDE_EFFECT, field, effect_id, v ) );
override_entries_.emplace_back( DBC_OVERRIDE_EFFECT, field, effect_id, v );
}

void dbc_override::register_power( dbc_t& dbc, unsigned power_id, const std::string& field, double v )
Expand All @@ -967,7 +967,7 @@ void dbc_override::register_power( dbc_t& dbc, unsigned power_id, const std::str
throw std::invalid_argument(fmt::format("Invalid field '{}'.", field));
}

override_entries_.push_back( dbc_override_entry_t( DBC_OVERRIDE_POWER, field, power_id, v ) );
override_entries_.emplace_back( DBC_OVERRIDE_POWER, field, power_id, v );
}

const spell_data_t* dbc_override::find_spell( unsigned spell_id, bool ptr )
Expand Down
6 changes: 3 additions & 3 deletions engine/dbc/sc_item_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ bool item_database::parse_item_spell_enchant( item_t& item,
es -> effectN( j + 1 ).subtype() == A_MOD_STAT &&
es -> effectN( j + 1 ).misc_value1() == -1 )
{
stats.push_back( stat_pair_t( STAT_ALL, static_cast<int>(es -> effectN( j + 1 ).average( item.player ) )) );
stats.emplace_back( STAT_ALL, static_cast<int>(es -> effectN( j + 1 ).average( item.player ) ) );
break;
}
}
Expand Down Expand Up @@ -1520,11 +1520,11 @@ static std::vector< std::tuple< item_mod_type, double, double > > get_bonus_id_s
{
if ( entries[ i ] -> type == ITEM_BONUS_MOD )
{
data.push_back( std::make_tuple(
data.emplace_back(
static_cast<item_mod_type>( entries[ i ] -> value_1 ),
entries[ i ] -> value_2 / total,
entries[ i ] -> value_2 / 10000.0
) );
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion engine/dbc/sc_spell_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ std::string spell_info::to_str( const dbc_t& dbc, const spell_data_t* spell, int
{
if ( spell->equipped_subclass_mask() & ( 1 << static_cast<unsigned>( wt ) ) )
{
weapon_types.push_back( util::weapon_subclass_string( wt ) );
weapon_types.emplace_back(util::weapon_subclass_string( wt ) );
}
}
s << "Requires weapon : ";
Expand Down
4 changes: 2 additions & 2 deletions engine/interfaces/sc_bcp_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ std::vector<std::string> token_paths()
{
std::vector<std::string> paths;

paths.push_back( "./simc-apitoken" );
paths.emplace_back("./simc-apitoken" );

if ( const char* home_path = getenv( "HOME" ) )
{
Expand Down Expand Up @@ -1267,7 +1267,7 @@ bool bcp_api::download_guild( sim_t* sim,
player_filter != util::translate_class_id( character[ "class" ].GetInt() ) )
continue;

names.push_back( character[ "name" ].GetString() );
names.emplace_back(character[ "name" ].GetString() );
}

if ( names.empty() ) return true;
Expand Down
16 changes: 8 additions & 8 deletions engine/player/azerite_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ bool azerite_essence_state_t::parse_azerite_essence( sim_t* sim,
// Check if the id is "0", and insert a placeholder into the slot state
if ( token_split[ 0 ].front() == '0' )
{
m_state.push_back( {} );
m_state.emplace_back( );
n_parsed_powers++;
continue;
}
Expand Down Expand Up @@ -1174,7 +1174,7 @@ bool azerite_essence_state_t::parse_azerite_essence( sim_t* sim,
return false;
}

m_state.push_back( { essence_type::PASSIVE, id, 1u } );
m_state.emplace_back( essence_type::PASSIVE, id, 1u );
break;
}
// Essence id, rank
Expand All @@ -1186,8 +1186,8 @@ bool azerite_essence_state_t::parse_azerite_essence( sim_t* sim,
return false;
}

m_state.push_back( { major_parsed ? essence_type::MINOR : essence_type::MAJOR,
id, rank } );
m_state.emplace_back( major_parsed ? essence_type::MINOR : essence_type::MAJOR,
id, rank );

if ( !major_parsed )
{
Expand All @@ -1207,7 +1207,7 @@ bool azerite_essence_state_t::parse_azerite_essence( sim_t* sim,

explicit_type = true;

m_state.push_back( { type, id, rank } );
m_state.emplace_back( type, id, rank );
break;
}
default:
Expand Down Expand Up @@ -1867,7 +1867,7 @@ void blood_rite( special_effect_t& effect )
return;
}

target->callbacks_on_demise.push_back( [buff]( player_t* ) {
target->callbacks_on_demise.emplace_back([buff]( player_t* ) {
if ( buff->up( ) )
{
buff->refresh();
Expand Down Expand Up @@ -5005,7 +5005,7 @@ void aegis_of_the_deep( special_effect_t& effect )
return;
}

target -> callbacks_on_arise.push_back( [ effect, aegis_buff ] ()
target -> callbacks_on_arise.emplace_back([ effect, aegis_buff ] ()
{
if ( aegis_buff )
{
Expand All @@ -5016,7 +5016,7 @@ void aegis_of_the_deep( special_effect_t& effect )
} );


target -> callbacks_on_demise.push_back( [ effect, aegis_buff ] ( player_t* target )
target -> callbacks_on_demise.emplace_back([ effect, aegis_buff ] ( player_t* target )
{
// Don't do anything if the sim is ending
if ( target -> sim -> event_mgr.canceled )
Expand Down
2 changes: 1 addition & 1 deletion engine/player/sc_enchant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ bool enchant::passive_enchant( item_t& item, unsigned spell_id )

if ( stat != STAT_NONE && value != 0 )
{
item.parsed.enchant_stats.push_back( stat_pair_t( stat, (int)value ) );
item.parsed.enchant_stats.emplace_back( stat, (int)value );
ret = true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions engine/player/sc_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@ void item_t::decode_gems()
{
throw std::invalid_argument(fmt::format("Invalid stat '{}'.", t.name));
}
parsed.gem_stats.push_back( stat_pair_t( s, static_cast<int>( t.value ) ) );
parsed.gem_stats.emplace_back( s, static_cast<int>( t.value ) );
}
}
catch (const std::exception&)
Expand Down Expand Up @@ -1792,7 +1792,7 @@ std::vector<stat_pair_t> item_t::str_to_stat_pair( const std::string& stat_str )
{
stat_e s = STAT_NONE;
if ( ( s = util::parse_stat_type( t.name ) ) != STAT_NONE && t.value != 0 )
stats.push_back( stat_pair_t( s, static_cast<int>( t.value ) ) );
stats.emplace_back( s, static_cast<int>( t.value ) );
}

return stats;
Expand Down
Loading

0 comments on commit 702bbfa

Please sign in to comment.