Skip to content

Commit

Permalink
More usage of string-view based string-split (simulationcraft#6207)
Browse files Browse the repository at this point in the history
  • Loading branch information
scamille authored Nov 21, 2021
1 parent 226a8fd commit 4f53fe1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
17 changes: 9 additions & 8 deletions engine/class_modules/sc_druid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9524,7 +9524,7 @@ double druid_t::composite_leech() const
// druid_t::create_action_expression ========================================
std::unique_ptr<expr_t> druid_t::create_action_expression(action_t& a, util::string_view name_str)
{
auto splits = util::string_split(name_str, ".");
auto splits = util::string_split<util::string_view>(name_str, ".");

if (splits[0] == "ticks_gained_on_refresh" || (splits.size() > 2 && (splits[0] == "druid" || splits[0] == "dot" ) && splits[2] == "ticks_gained_on_refresh"))
{
Expand All @@ -9534,16 +9534,17 @@ std::unique_ptr<expr_t> druid_t::create_action_expression(action_t& a, util::str

action_t* dot_action = nullptr;

if (splits.size() > 2)
if ( splits.size() > 2 )
{
if (splits[1] == "moonfire_cat")
dot_action = find_action("lunar_inspiration");
else if (splits[1] == "rake")
dot_action = find_action("rake_bleed");
if ( splits[ 1 ] == "moonfire_cat" )
dot_action = find_action( "lunar_inspiration" );
else if ( splits[ 1 ] == "rake" )
dot_action = find_action( "rake_bleed" );
else
dot_action = find_action(splits[1]);
dot_action = find_action( splits[ 1 ] );

if (!dot_action) throw std::invalid_argument("invalid action specified in ticks_gained_on_refresh");
if ( !dot_action )
throw std::invalid_argument( "invalid action specified in ticks_gained_on_refresh" );
}
else
dot_action = &a;
Expand Down
4 changes: 2 additions & 2 deletions engine/class_modules/sc_shaman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7400,11 +7400,11 @@ void shaman_t::create_pets()

std::unique_ptr<expr_t> shaman_t::create_expression( util::string_view name )
{
std::vector<std::string> splits = util::string_split( name, "." );
auto splits = util::string_split<util::string_view>( name, "." );

if ( splits.size() >= 3 && util::str_compare_ci( splits[ 0 ], "pet" ) )
{
auto require_primal = splits[ 1 ].find( "primal_" ) != std::string::npos;
auto require_primal = splits[ 1 ].find( "primal_" ) != util::string_view::npos;
auto et = elemental::FIRE;
if ( util::str_in_str_ci( splits[ 1 ], "fire" ) )
{
Expand Down
2 changes: 1 addition & 1 deletion engine/item/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ void item_t::parse_options()
{
try
{
auto split = util::string_split( option_crafted_stat_str, "/" );
auto split = util::string_split<util::string_view>( option_crafted_stat_str, "/" );
if ( split.size() > 2 )
{
throw std::invalid_argument( "Maximum of two crafted stats can exist on an item." );
Expand Down
4 changes: 2 additions & 2 deletions engine/player/sc_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1689,10 +1689,10 @@ void player_t::parse_temporary_enchants()
return;
}

auto split = util::string_split( tench_str, "/" );
auto split = util::string_split<util::string_view>( tench_str, "/" );
for ( const auto& token : split )
{
auto token_split = util::string_split( token, ":" );
auto token_split = util::string_split<util::string_view>( token, ":" );
if ( token_split.size() != 2 )
{
sim->error( "Player {} invalid temporary enchant token {}, format is 'slot:name'",
Expand Down
2 changes: 1 addition & 1 deletion engine/sim/sc_profileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ void create_options( sim_t* sim )
auto split = util::string_split( value, "/:," );
for ( const auto& v : split )
{
sim -> profileset_output_data.push_back( v );
sim -> profileset_output_data.push_back( std::move( v ) );
}

return true;
Expand Down

0 comments on commit 4f53fe1

Please sign in to comment.