mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 09:31:30 +00:00
Switch scheduled hot zone check to search instead of split (#1313)
Using search_deliminated_string here is significantly faster than splitting, most likely because of dynamic memory management Some tests on my system: ---------------------------------------------------- Benchmark Time CPU Iterations ---------------------------------------------------- bench_split 864 ns 864 ns 807922 bench_search 35 ns 35 ns 20265205 This test was a case where the string was present somewhere in the middle which gave a ~96% speed up ---------------------------------------------------- Benchmark Time CPU Iterations ---------------------------------------------------- bench_split 936 ns 936 ns 725518 bench_search 61 ns 61 ns 11156359 This test was when the string was not present, which will be the vast majority of times this is actually checked, was ~93% speed up
This commit is contained in:
parent
050e78b1b6
commit
0534a2c6be
@ -35,11 +35,8 @@ void ZoneEventScheduler::Process(Zone *zone, WorldContentService *content_servic
|
||||
LogSchedulerDetail("Looping active event validated [{}]", e.event_type);
|
||||
if (e.event_type == ServerEvents::EVENT_TYPE_HOT_ZONE_ACTIVE) {
|
||||
LogScheduler("Deactivating event [{}] disabling hotzone status", e.description);
|
||||
for (auto &short_name: split(e.event_data, ',')) {
|
||||
if (zone->GetShortName() == short_name) {
|
||||
if (search_deliminated_string(e.event_data, zone->GetShortName()) != std::string::npos) {
|
||||
zone->SetIsHotzone(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
RemoveActiveEvent(e);
|
||||
}
|
||||
@ -88,12 +85,9 @@ void ZoneEventScheduler::Process(Zone *zone, WorldContentService *content_servic
|
||||
// such as broadcasts, reloads
|
||||
if (ValidateEventReadyToActivate(e) && !IsEventActive(e)) {
|
||||
if (e.event_type == ServerEvents::EVENT_TYPE_HOT_ZONE_ACTIVE) {
|
||||
for (auto &short_name: split(e.event_data, ',')) {
|
||||
if (zone->GetShortName() == short_name) {
|
||||
if (search_deliminated_string(e.event_data, zone->GetShortName()) != std::string::npos) {
|
||||
zone->SetIsHotzone(true);
|
||||
LogScheduler("Activating Event [{}] Enabling zone as hotzone", e.description);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_active_events.push_back(e);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user