[Strings] Split String Optimizations (#1325)

* Switch the 2 split calls to SplitString

* Nuke duplicate split in favor of SplitString #1263

* Add a test for SplitString

* Optimize SplitString

Benchmarking:
--------------------------------------------------------------
Benchmark                       Time           CPU Iterations
--------------------------------------------------------------
bench_oldsplit               5201 ns       5201 ns     129500
bench_split                  1269 ns       1269 ns     548906

This is splitting a VERY long SpecialAbilities string. This is ~75%
speed up.
This commit is contained in:
Michael Cook (mackal)
2021-04-23 00:36:39 -04:00
committed by GitHub
parent 00fb9bc9f9
commit dba3010c89
5 changed files with 24 additions and 24 deletions
+1 -1
View File
@@ -557,7 +557,7 @@ inline std::string WriteDisplayInfoSection(
* "total_to_hit" = "Total To Hit"
*/
if (attribute_name.find('_') != std::string::npos) {
std::vector<std::string> split_string = split(attribute_name, '_');
auto split_string = SplitString(attribute_name, '_');
std::string new_attribute_name;
for (std::string &string_value : split_string) {
new_attribute_name += ucfirst(string_value) + " ";
+1 -1
View File
@@ -93,7 +93,7 @@ void ZoneEventScheduler::Process(Zone *zone, WorldContentService *content_servic
}
if (e.event_type == ServerEvents::EVENT_TYPE_RULE_CHANGE) {
auto params = split(e.event_data, '=');
auto params = SplitString(e.event_data, '=');
auto rule_key = params[0];
auto rule_value = params[1];
if (!rule_key.empty() && !rule_value.empty()) {