From fcdeeba7ed343dfeb70694ca2da213f646bbcd20 Mon Sep 17 00:00:00 2001 From: Andreas Maerten <24669514+Yimura@users.noreply.github.com> Date: Mon, 22 Apr 2024 19:48:22 +0200 Subject: [PATCH] Give optimisation hints to compiler (#2929) feat(invoker): add compiler hints chore(get network event data): added translation TODO feat(native hooks): add compiler hint to crashes feat(render): add likely compiler hint to on_present feat(thread pool): add compiler hints Added hook likely/unlikely switches to debug/crash scenarios. Added HEX_TO_UPPER call on the AC verifier offsets. Added more fuzzer unlikely attributes. Replaced some hard coded numbers with their unhashed _J variants. Added more unlikely attributes to singleton initializer checks. Added more likely/unlikely attributes to certain scenarios. --- src/backend/looped/self/godmode.cpp | 4 +-- src/backend/looped/self/no_collision.cpp | 4 +-- .../looped/self/no_water_collision.cpp | 4 +-- src/backend/looped/self/persist_outfit.cpp | 24 ++++++++--------- src/backend/looped/self/police.cpp | 2 +- src/backend/looped/self/toggle_passive.cpp | 8 +++--- src/backend/looped/self/unlimited_oxygen.cpp | 2 +- src/backend/looped/system/self_globals.cpp | 4 +-- .../tunables/allow_weapons_in_interiors.cpp | 7 ++--- .../vehicle/allow_all_vehicles_in_heists.cpp | 2 +- .../looped/vehicle/allow_all_weapons.cpp | 15 +++++------ .../looped/weapons/do_persist_weapons.cpp | 2 +- src/hooks/fuzzer/read_bits_single.cpp | 2 +- src/hooks/fuzzer/sync_data_reader.cpp | 26 +++++++++---------- src/hooks/gui/wndproc.cpp | 2 +- src/hooks/info/get_network_event_data.cpp | 2 +- src/hooks/misc/http_start_request.cpp | 2 +- src/hooks/misc/queue_dependency.cpp | 12 ++++----- .../protections/allocate_memory_reliable.cpp | 4 +-- .../protections/fragment_physics_crash.cpp | 2 +- src/hooks/protections/handle_join_request.cpp | 4 +-- src/hooks/protections/invalid_decal.cpp | 8 +++--- .../protections/invalid_mods_crash_detour.cpp | 2 +- .../protections/received_clone_create.cpp | 6 ++--- .../protections/received_clone_remove.cpp | 2 +- src/hooks/protections/received_clone_sync.cpp | 8 +++--- src/hooks/protections/received_event.cpp | 6 ++--- src/hooks/protections/render_big_ped.cpp | 4 +-- src/hooks/protections/render_entity.cpp | 4 +-- src/hooks/protections/render_ped.cpp | 4 +-- .../protections/serialize_parachute_task.cpp | 2 +- .../serialize_take_off_ped_variation_task.cpp | 2 +- src/hooks/protections/task_ambient_clips.cpp | 2 +- .../protections/task_parachute_object.cpp | 8 +++--- src/hooks/script/run_script_threads.cpp | 2 +- src/invoker/invoker.hpp | 12 +++++---- src/native_hooks/all_scripts.hpp | 4 +-- src/renderer/renderer.cpp | 4 +-- .../persist_weapons/persist_weapons.cpp | 4 +-- src/thread_pool.cpp | 6 ++--- 40 files changed, 113 insertions(+), 111 deletions(-) diff --git a/src/backend/looped/self/godmode.cpp b/src/backend/looped/self/godmode.cpp index 29703764..6a37c4ac 100644 --- a/src/backend/looped/self/godmode.cpp +++ b/src/backend/looped/self/godmode.cpp @@ -12,7 +12,7 @@ namespace big virtual void on_tick() override { - if (g_local_player == nullptr) + if (g_local_player == nullptr) [[unlikely]] { return; } @@ -21,7 +21,7 @@ namespace big uint32_t changed_bits = bits ^ last_bits; uint32_t changed_or_enabled_bits = bits | changed_bits; - if (changed_or_enabled_bits) + if (changed_or_enabled_bits) [[unlikely]] { uint32_t unchanged_bits = g_local_player->m_damage_bits & ~changed_or_enabled_bits; g_local_player->m_damage_bits = unchanged_bits | bits; diff --git a/src/backend/looped/self/no_collision.cpp b/src/backend/looped/self/no_collision.cpp index 36e2fe49..b82228d4 100644 --- a/src/backend/looped/self/no_collision.cpp +++ b/src/backend/looped/self/no_collision.cpp @@ -14,7 +14,7 @@ namespace big virtual void on_tick() override { - if (g_local_player) + if (g_local_player) [[likely]] ((rage::phBoundComposite*)g_local_player->m_navigation->m_damp->m_bound) ->m_bounds[0] ->m_bounding_box_max_xyz_margin_w.w = -1; @@ -22,7 +22,7 @@ namespace big virtual void on_disable() override { - if (g_local_player) + if (g_local_player) [[likely]] ((rage::phBoundComposite*)g_local_player->m_navigation->m_damp->m_bound) ->m_bounds[0] ->m_bounding_box_max_xyz_margin_w.w = 0.25; diff --git a/src/backend/looped/self/no_water_collision.cpp b/src/backend/looped/self/no_water_collision.cpp index 3bf322c2..fca530d6 100644 --- a/src/backend/looped/self/no_water_collision.cpp +++ b/src/backend/looped/self/no_water_collision.cpp @@ -11,13 +11,13 @@ namespace big virtual void on_tick() override { - if (g_local_player) + if (g_local_player) [[likely]] g_local_player->m_navigation->m_damp->m_water_collision = 0; } virtual void on_disable() override { - if (g_local_player) + if (g_local_player) [[likely]] g_local_player->m_navigation->m_damp->m_water_collision = 1; } }; diff --git a/src/backend/looped/self/persist_outfit.cpp b/src/backend/looped/self/persist_outfit.cpp index 5af1966e..d9574de5 100644 --- a/src/backend/looped/self/persist_outfit.cpp +++ b/src/backend/looped/self/persist_outfit.cpp @@ -15,13 +15,13 @@ namespace big int offset = 0; switch (model) { - case "mp_m_freemode_01"_J: break; - case "mp_f_freemode_01"_J: - { - offset = 1; - break; - } - default: return false; //For non-normal models + case "mp_m_freemode_01"_J: [[likely]] break; + case "mp_f_freemode_01"_J: [[likely]] + { + offset = 1; + break; + } + default:[[unlikely]] return false; //For non-normal models } return PED::GET_PED_DRAWABLE_VARIATION(self::ped, ComponentId::AUXILIARY) == 15 && PED::GET_PED_DRAWABLE_VARIATION(self::ped, ComponentId::TORSO) == 15 && PED::GET_PED_DRAWABLE_VARIATION(self::ped, ComponentId::LEGS) == (14 + offset); @@ -31,17 +31,17 @@ namespace big { //Disable clothing validation *scr_globals::reset_clothing.as() = FALSE; - if (auto tunable = g_tunables_service->get_tunable("DISABLE_CLOTHING_SAVE_SLOT_VALIDATION"_J)) + if (auto tunable = g_tunables_service->get_tunable("DISABLE_CLOTHING_SAVE_SLOT_VALIDATION"_J)) [[likely]] *tunable = TRUE; if (g.self.persist_outfit.empty()) return; //Off - if (g_local_player == nullptr || PED::IS_PED_DEAD_OR_DYING(self::ped, TRUE) || STREAMING::IS_PLAYER_SWITCH_IN_PROGRESS() || DLC::GET_IS_LOADING_SCREEN_ACTIVE()) + if (g_local_player == nullptr || PED::IS_PED_DEAD_OR_DYING(self::ped, TRUE) || STREAMING::IS_PLAYER_SWITCH_IN_PROGRESS() || DLC::GET_IS_LOADING_SCREEN_ACTIVE()) [[unlikely]] return; //Dead or Loading auto model = ENTITY::GET_ENTITY_MODEL(self::ped); - if (is_taking_shower(model)) + if (is_taking_shower(model)) [[unlikely]] return; //Showering if (g.self.persist_outfits_mis && NETWORK::NETWORK_IS_ACTIVITY_SESSION()) @@ -55,10 +55,10 @@ namespace big persisting_outfit = g.self.persist_outfit; folder saved_outfit_path = g_file_manager.get_project_folder("saved_outfits"); const auto persist_outfit_file_path = saved_outfit_path.get_file(persisting_outfit).get_path(); - if (std::filesystem::exists(persist_outfit_file_path)) + if (std::filesystem::exists(persist_outfit_file_path)) [[likely]] { std::ifstream i(persist_outfit_file_path); - if (i.is_open()) + if (i.is_open()) [[likely]] { outfit.clear(); try diff --git a/src/backend/looped/self/police.cpp b/src/backend/looped/self/police.cpp index da17f980..cb43874d 100644 --- a/src/backend/looped/self/police.cpp +++ b/src/backend/looped/self/police.cpp @@ -6,7 +6,7 @@ namespace big { void looped::self_police() { - if (g_local_player == nullptr || g_local_player->m_player_info == nullptr) + if (g_local_player == nullptr || g_local_player->m_player_info == nullptr) [[unlikely]] return; static bool bLast = false; diff --git a/src/backend/looped/self/toggle_passive.cpp b/src/backend/looped/self/toggle_passive.cpp index 84bbccc0..59e1e9cd 100644 --- a/src/backend/looped/self/toggle_passive.cpp +++ b/src/backend/looped/self/toggle_passive.cpp @@ -15,22 +15,22 @@ namespace big virtual void on_tick() override { - if (scr_globals::gpbd_fm_3.as()->Entries[self::id].BossGoon.Boss != -1 || gta_util::find_script_thread("fm_mission_controller"_J) || gta_util::find_script_thread("fm_mission_controller_2020"_J)) + if (scr_globals::gpbd_fm_3.as()->Entries[self::id].BossGoon.Boss != -1 || gta_util::find_script_thread("fm_mission_controller"_J) || gta_util::find_script_thread("fm_mission_controller_2020"_J)) [[unlikely]] { on_disable(); g.self.passive = false; g_notification_service.push_warning("PASSIVE"_T.data(), "BACKEND_LOOPED_SELF_TOGGLE_PASSIVE_DISABLED_PASSIVE_MODE_MESSAGE"_T.data()); return; } - *g_tunables_service->get_tunable(-29732167) = 0; // End Passive Time = 0s - *scr_globals::passive.as() = TRUE; + *g_tunables_service->get_tunable("VC_PASSIVE_TIME_AFTER_DISABLE"_J) = 0; // End Passive Time = 0s + *scr_globals::passive.as() = TRUE; } virtual void on_disable() override { *scr_globals::passive.as() = FALSE; NETWORK::SET_LOCAL_PLAYER_AS_GHOST(false, false); - *g_tunables_service->get_tunable(-29732167) = 30000; + *g_tunables_service->get_tunable("VC_PASSIVE_TIME_AFTER_DISABLE"_J) = 30000; PED::SET_PED_CONFIG_FLAG(self::ped, 342, false); // Disable NotAllowedToJackAnyPlayers PED::SET_PED_CONFIG_FLAG(self::ped, 122, false); // Disable DisableMelee PLAYER::SET_PLAYER_VEHICLE_DEFENSE_MODIFIER(self::ped, 1.f); diff --git a/src/backend/looped/self/unlimited_oxygen.cpp b/src/backend/looped/self/unlimited_oxygen.cpp index 830901ac..c6184f37 100644 --- a/src/backend/looped/self/unlimited_oxygen.cpp +++ b/src/backend/looped/self/unlimited_oxygen.cpp @@ -11,7 +11,7 @@ namespace big virtual void on_tick() override { - if (g_local_player) + if (g_local_player) [[likely]] g_local_player->m_ped_intelligence->m_oxygen_time = 0; } }; diff --git a/src/backend/looped/system/self_globals.cpp b/src/backend/looped/system/self_globals.cpp index 469a6353..d3b20bab 100644 --- a/src/backend/looped/system/self_globals.cpp +++ b/src/backend/looped/system/self_globals.cpp @@ -9,9 +9,9 @@ namespace big void looped::system_self_globals() { if (!*g_pointers->m_gta.m_network_player_mgr || !(*g_pointers->m_gta.m_network_player_mgr)->m_local_net_player - || (*g_pointers->m_gta.m_network_player_mgr)->m_local_net_player->m_player_id == -1) + || (*g_pointers->m_gta.m_network_player_mgr)->m_local_net_player->m_player_id == -1) [[unlikely]] self::id = 0; - else + else [[likely]] self::id = (*g_pointers->m_gta.m_network_player_mgr)->m_local_net_player->m_player_id; self::ped = PLAYER::PLAYER_PED_ID(); diff --git a/src/backend/looped/tunables/allow_weapons_in_interiors.cpp b/src/backend/looped/tunables/allow_weapons_in_interiors.cpp index 31cbb993..42fbe07b 100644 --- a/src/backend/looped/tunables/allow_weapons_in_interiors.cpp +++ b/src/backend/looped/tunables/allow_weapons_in_interiors.cpp @@ -9,15 +9,16 @@ namespace big virtual void on_tick() override { - if (auto tunable = g_tunables_service->get_tunable(-298441869)) + if (auto tunable = g_tunables_service->get_tunable("KICK_OUT_OF_NIGHTCLUB_WITH_WEAPON"_J)) [[likely]] { - *tunable = FALSE; + if (*tunable == TRUE) [[unlikely]] + *tunable = FALSE; } } virtual void on_disable() override { - if (auto tunable = g_tunables_service->get_tunable(-298441869)) + if (auto tunable = g_tunables_service->get_tunable("KICK_OUT_OF_NIGHTCLUB_WITH_WEAPON"_J)) [[likely]] { *tunable = TRUE; } diff --git a/src/backend/looped/vehicle/allow_all_vehicles_in_heists.cpp b/src/backend/looped/vehicle/allow_all_vehicles_in_heists.cpp index 6b7a1249..79222851 100644 --- a/src/backend/looped/vehicle/allow_all_vehicles_in_heists.cpp +++ b/src/backend/looped/vehicle/allow_all_vehicles_in_heists.cpp @@ -16,7 +16,7 @@ namespace big { for (Hash tunable_hash : list_of_hashes) { - if (auto tunable_ptr = g_tunables_service->get_tunable(tunable_hash)) + if (auto tunable_ptr = g_tunables_service->get_tunable(tunable_hash)) [[likely]] { if (*tunable_ptr != FALSE) { diff --git a/src/backend/looped/vehicle/allow_all_weapons.cpp b/src/backend/looped/vehicle/allow_all_weapons.cpp index 73aea5cf..dc53d690 100644 --- a/src/backend/looped/vehicle/allow_all_weapons.cpp +++ b/src/backend/looped/vehicle/allow_all_weapons.cpp @@ -12,21 +12,20 @@ namespace big { void looped::vehicle_allow_all_weapons() { - if (g_local_player == nullptr || g_local_player->m_vehicle == nullptr) + if (g_local_player == nullptr || g_local_player->m_vehicle == nullptr) [[unlikely]] return; auto seat_info = g_pointers->m_gta.m_get_ped_seat(g_local_player->m_seat_info, g_local_player); - - if (seat_info == nullptr) + if (seat_info == nullptr) [[unlikely]] return; if (g.vehicle.unlimited_weapons == false) { - if (seat_info->anim_info) + if (seat_info->anim_info) [[likely]] { for (auto drive_by_anim_info : seat_info->anim_info->m_drive_by_anim_infos) { - if (drive_by_anim_info->m_weapon_groups->m_groups.size() == 7 && drive_by_anim_info->m_weapon_groups->m_groups.contains(GROUP_PISTOL)) + if (drive_by_anim_info->m_weapon_groups->m_groups.size() == 7 && drive_by_anim_info->m_weapon_groups->m_groups.contains(GROUP_PISTOL)) [[unlikely]] { drive_by_anim_info->m_weapon_groups->m_groups.clear(); drive_by_anim_info->m_weapon_groups->m_groups.append({GROUP_PISTOL}); @@ -36,21 +35,21 @@ namespace big return; } - if (seat_info->anim_info == nullptr) //Should only occur in the R-88 and similar formula cars, so assume the user is in the driver's seat. Fix later, if other edge cases occur. + if (seat_info->anim_info == nullptr) [[unlikely]] //Should only occur in the R-88 and similar formula cars, so assume the user is in the driver's seat. Fix later, if other edge cases occur. { seat_info->anim_info = g_pointers->m_gta.m_vehicle_layout_metadata_mgr->m_drive_by_seat_defaults->m_driveby_standard_front_left; } for (auto drive_by_anim_info : seat_info->anim_info->m_drive_by_anim_infos) { - if (drive_by_anim_info->m_weapon_groups->m_groups.size() != 7 && drive_by_anim_info->m_weapon_groups->m_groups.contains(GROUP_PISTOL)) + if (drive_by_anim_info->m_weapon_groups->m_groups.size() != 7 && drive_by_anim_info->m_weapon_groups->m_groups.contains(GROUP_PISTOL)) [[unlikely]] { drive_by_anim_info->m_weapon_groups->m_groups.clear(); drive_by_anim_info->m_weapon_groups->m_groups.append({GROUP_PISTOL, GROUP_MG, GROUP_RIFLE, GROUP_SHOTGUN, GROUP_HEAVY, GROUP_SNIPER, GROUP_SMG}); } } - if (auto vehicle_model_info = static_cast(g_local_player->m_vehicle->m_model_info)) + if (auto vehicle_model_info = static_cast(g_local_player->m_vehicle->m_model_info)) [[likely]] { vehicle_model_info->set_vehicle_model_flag(CVehicleModelInfoFlags::DRIVER_NO_DRIVE_BY, false); if (PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) diff --git a/src/backend/looped/weapons/do_persist_weapons.cpp b/src/backend/looped/weapons/do_persist_weapons.cpp index 30921a24..384f20c8 100644 --- a/src/backend/looped/weapons/do_persist_weapons.cpp +++ b/src/backend/looped/weapons/do_persist_weapons.cpp @@ -11,7 +11,7 @@ namespace big const auto elapsed_time_in_ms = std::chrono::duration_cast(time_now - last_time); - if (elapsed_time_in_ms >= 500ms) + if (elapsed_time_in_ms >= 500ms) [[unlikely]] { last_time = time_now; diff --git a/src/hooks/fuzzer/read_bits_single.cpp b/src/hooks/fuzzer/read_bits_single.cpp index 0f2ef1ec..0c45ebc5 100644 --- a/src/hooks/fuzzer/read_bits_single.cpp +++ b/src/hooks/fuzzer/read_bits_single.cpp @@ -8,7 +8,7 @@ namespace big { auto orig = g_hooking->get_original()(data, out_value, size, offset); - if (fuzzer::is_fuzzer_enabled()) + if (fuzzer::is_fuzzer_enabled()) [[unlikely]] { fuzzer::handle_vtable_write(out_value, sizeof(int), __FUNCTION__); *out_value = fuzzer::fuzz_bits(*out_value, size); diff --git a/src/hooks/fuzzer/sync_data_reader.cpp b/src/hooks/fuzzer/sync_data_reader.cpp index a50e1566..a715ab6b 100644 --- a/src/hooks/fuzzer/sync_data_reader.cpp +++ b/src/hooks/fuzzer/sync_data_reader.cpp @@ -7,7 +7,7 @@ namespace big { auto orig = g_hooking->m_sync_data_reader_hook.get_original(1)(_this, dword, size); - if (fuzzer::is_fuzzer_enabled()) + if (fuzzer::is_fuzzer_enabled()) [[unlikely]] { fuzzer::handle_vtable_write(dword, sizeof(uint32_t), __FUNCTION__); *dword = fuzzer::fuzz_bits(*dword, size); @@ -21,7 +21,7 @@ namespace big { auto orig = g_hooking->m_sync_data_reader_hook.get_original(2)(_this, word, size); - if (fuzzer::is_fuzzer_enabled()) + if (fuzzer::is_fuzzer_enabled()) [[unlikely]] { fuzzer::handle_vtable_write(word, sizeof(uint16_t), __FUNCTION__); *word = fuzzer::fuzz_bits(*word, size); @@ -35,7 +35,7 @@ namespace big { auto orig = g_hooking->m_sync_data_reader_hook.get_original(3)(_this, byte, size); - if (fuzzer::is_fuzzer_enabled()) + if (fuzzer::is_fuzzer_enabled()) [[unlikely]] { fuzzer::handle_vtable_write(byte, sizeof(uint8_t), __FUNCTION__); *byte = fuzzer::fuzz_bits(*byte, size); @@ -49,7 +49,7 @@ namespace big { auto orig = g_hooking->m_sync_data_reader_hook.get_original(4)(_this, i, size); - if (fuzzer::is_fuzzer_enabled()) + if (fuzzer::is_fuzzer_enabled()) [[unlikely]] { fuzzer::handle_vtable_write(i, sizeof(int32_t), __FUNCTION__); *i = fuzzer::fuzz_signed_bits(*i, size); @@ -63,7 +63,7 @@ namespace big { auto orig = g_hooking->m_sync_data_reader_hook.get_original(5)(_this, i, size); - if (fuzzer::is_fuzzer_enabled()) + if (fuzzer::is_fuzzer_enabled()) [[unlikely]] { fuzzer::handle_vtable_write(i, sizeof(int16_t), __FUNCTION__); *i = fuzzer::fuzz_signed_bits(*i, size); @@ -77,7 +77,7 @@ namespace big { auto orig = g_hooking->m_sync_data_reader_hook.get_original(6)(_this, i, size); - if (fuzzer::is_fuzzer_enabled()) + if (fuzzer::is_fuzzer_enabled()) [[unlikely]] { fuzzer::handle_vtable_write(i, sizeof(int8_t), __FUNCTION__); *i = fuzzer::fuzz_signed_bits(*i, size); @@ -91,7 +91,7 @@ namespace big { auto orig = g_hooking->m_sync_data_reader_hook.get_original(7)(_this, flag, size); - if (fuzzer::is_fuzzer_enabled()) + if (fuzzer::is_fuzzer_enabled()) [[unlikely]] { fuzzer::handle_vtable_write(flag, sizeof(bool), __FUNCTION__); *flag = fuzzer::fuzz_bool(*flag); @@ -105,7 +105,7 @@ namespace big { auto orig = g_hooking->m_sync_data_reader_hook.get_original(16)(_this, flt, divisor, size); - if (fuzzer::is_fuzzer_enabled()) + if (fuzzer::is_fuzzer_enabled()) [[unlikely]] { fuzzer::handle_vtable_write(flt, sizeof(float), __FUNCTION__); *flt = fuzzer::fuzz_float(*flt, size, divisor, true); @@ -119,7 +119,7 @@ namespace big { auto orig = g_hooking->m_sync_data_reader_hook.get_original(17)(_this, flt, divisor, size); - if (fuzzer::is_fuzzer_enabled()) + if (fuzzer::is_fuzzer_enabled()) [[unlikely]] { fuzzer::handle_vtable_write(flt, sizeof(float), __FUNCTION__); *flt = fuzzer::fuzz_float(*flt, size, divisor, false); @@ -133,7 +133,7 @@ namespace big { auto orig = g_hooking->m_sync_data_reader_hook.get_original(18)(_this, id); - if (fuzzer::is_fuzzer_enabled()) + if (fuzzer::is_fuzzer_enabled()) [[unlikely]] { fuzzer::handle_vtable_write(id, sizeof(uint16_t), __FUNCTION__); *id = fuzzer::fuzz_network_id(*id); @@ -147,7 +147,7 @@ namespace big { auto orig = g_hooking->m_sync_data_reader_hook.get_original(19)(_this, vec, divisor, size); - if (fuzzer::is_fuzzer_enabled()) + if (fuzzer::is_fuzzer_enabled()) [[unlikely]] { fuzzer::handle_vtable_write(vec, sizeof(rage::fvector3), __FUNCTION__); *vec = fuzzer::fuzz_vector(*vec, size, divisor, false); @@ -161,7 +161,7 @@ namespace big { auto orig = g_hooking->m_sync_data_reader_hook.get_original(21)(_this, vec, divisor, size); - if (fuzzer::is_fuzzer_enabled()) + if (fuzzer::is_fuzzer_enabled()) [[unlikely]] { fuzzer::handle_vtable_write(vec, sizeof(rage::fvector3), __FUNCTION__); *vec = fuzzer::fuzz_vector(*vec, size, divisor, true); @@ -175,7 +175,7 @@ namespace big { auto orig = g_hooking->m_sync_data_reader_hook.get_original(23)(_this, array, size); - if (fuzzer::is_fuzzer_enabled()) + if (fuzzer::is_fuzzer_enabled()) [[unlikely]] { fuzzer::handle_vtable_write(array, size / 8, __FUNCTION__); fuzzer::fuzz_data(array, size / 8); diff --git a/src/hooks/gui/wndproc.cpp b/src/hooks/gui/wndproc.cpp index 60e6418d..86eb8368 100644 --- a/src/hooks/gui/wndproc.cpp +++ b/src/hooks/gui/wndproc.cpp @@ -6,7 +6,7 @@ namespace big { LRESULT hooks::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { - if (g_running) + if (g_running) [[likely]] { g_renderer.wndproc(hwnd, msg, wparam, lparam); } diff --git a/src/hooks/info/get_network_event_data.cpp b/src/hooks/info/get_network_event_data.cpp index f4bd962e..1de4f8ef 100644 --- a/src/hooks/info/get_network_event_data.cpp +++ b/src/hooks/info/get_network_event_data.cpp @@ -64,7 +64,7 @@ namespace big g_fiber_pool->queue_job([] { session::join_session(gta_util::get_network()->m_last_joined_session.m_session_info); }); - g_notification_service.push_warning("KICKED"_T.data(), "You have been desync kicked. Rejoining previous session..."); + g_notification_service.push_warning("KICKED"_T.data(), "You have been desync kicked. Rejoining previous session..."); // TODO: add to translations } else { diff --git a/src/hooks/misc/http_start_request.cpp b/src/hooks/misc/http_start_request.cpp index b4b933d1..12d91dc1 100644 --- a/src/hooks/misc/http_start_request.cpp +++ b/src/hooks/misc/http_start_request.cpp @@ -7,7 +7,7 @@ namespace big { bool hooks::http_start_request(void* request, const char* uri) { - if (strstr(uri, "Bonus")) + if (strstr(uri, "Bonus")) [[unlikely]] { // This is for worst case scenario where a report does slip through the cracks... // Lets make it go somewhere it doesn't matter -- don't let the reports reach their servers! diff --git a/src/hooks/misc/queue_dependency.cpp b/src/hooks/misc/queue_dependency.cpp index 68b81465..e7c7c05b 100644 --- a/src/hooks/misc/queue_dependency.cpp +++ b/src/hooks/misc/queue_dependency.cpp @@ -7,11 +7,11 @@ namespace big { bool inline is_address_in_game_region(int64_t address) { - if(!address) + if(!address) [[unlikely]] return false; static int64_t moduleBase = NULL; static int64_t moduleSize = NULL; - if (!moduleBase || !moduleSize) + if (!moduleBase || !moduleSize) [[unlikely]] { MODULEINFO info; if (!GetModuleInformation(GetCurrentProcess(), GetModuleHandle(0), &info, sizeof(info))) @@ -42,10 +42,10 @@ namespace big int64_t f2 = *reinterpret_cast(cb + 0x100); int64_t f3 = *reinterpret_cast(cb + 0x1A0); - if (!is_address_in_game_region(f1) || !is_address_in_game_region(f2) || !is_address_in_game_region(f3)) + if (!is_address_in_game_region(f1) || !is_address_in_game_region(f2) || !is_address_in_game_region(f3)) [[likely]] return false; - if(*reinterpret_cast(f1) != 0xE9) + if(*reinterpret_cast(f1) != 0xE9) [[likely]] return false; return true; @@ -58,9 +58,9 @@ namespace big int hooks::queue_dependency(void* a1, int a2, int64_t dependency) { - if (is_unwanted_dependency(dependency)) + if (is_unwanted_dependency(dependency)) [[unlikely]] { - LOG(INFO) << "Blocking AC Verifier " << std::hex << *reinterpret_cast(dependency + 0x60) - reinterpret_cast(GetModuleHandleA(0)); + LOG(INFO) << "Blocking AC Verifier " << HEX_TO_UPPER(*reinterpret_cast(dependency + 0x60) - reinterpret_cast(GetModuleHandle(NULL))); ac_verifier* verifier = reinterpret_cast(dependency - 0x30); verifier->m_delay = INT_MAX; // makes it so these won't queue in the future *reinterpret_cast(dependency + 0x60) = nullsub; diff --git a/src/hooks/protections/allocate_memory_reliable.cpp b/src/hooks/protections/allocate_memory_reliable.cpp index 1bd0b9a7..f99ac461 100644 --- a/src/hooks/protections/allocate_memory_reliable.cpp +++ b/src/hooks/protections/allocate_memory_reliable.cpp @@ -24,12 +24,12 @@ namespace big void* hooks::allocate_memory_reliable(rage::netConnection* cxn, int required_memory) { - if (!cxn || !required_memory) + if (!cxn || !required_memory) [[unlikely]] return nullptr; auto memory = reinterpret_cast(cxn->m_allocator)->Allocate(required_memory, 0, 0); - if (memory) + if (memory) [[likely]] return memory; LOG(WARNING) << "Failed to allocate " << required_memory << " bytes for reliable message, free space: " diff --git a/src/hooks/protections/fragment_physics_crash.cpp b/src/hooks/protections/fragment_physics_crash.cpp index cd7fde70..b6d98964 100644 --- a/src/hooks/protections/fragment_physics_crash.cpp +++ b/src/hooks/protections/fragment_physics_crash.cpp @@ -4,7 +4,7 @@ namespace big { bool hooks::fragment_physics_crash_2(float* a1, float* a2) { - if (!a1 || !a2) + if (!a1 || !a2) [[unlikely]] return false; return g_hooking->get_original()(a1, a2); diff --git a/src/hooks/protections/handle_join_request.cpp b/src/hooks/protections/handle_join_request.cpp index bbb8ab58..15ea1bd6 100644 --- a/src/hooks/protections/handle_join_request.cpp +++ b/src/hooks/protections/handle_join_request.cpp @@ -11,7 +11,7 @@ namespace big bool hooks::handle_join_request(Network* network, rage::snSession* session, rage::rlGamerInfo* player_info, CJoinRequestContext* ctx, BOOL is_transition_session) { if (auto player = g_player_database_service->get_player_by_rockstar_id(player_info->m_gamer_handle.m_rockstar_id); - player && player->block_join) + player && player->block_join) [[unlikely]] { CMsgJoinResponse response{}; response.m_status_code = player->block_join_reason; @@ -20,7 +20,7 @@ namespace big std::vformat("BLOCK_JOIN_INFO"_T, std::make_format_args(player->name))); return false; } - else + else [[likely]] { return g_hooking->get_original()(network, session, player_info, ctx, is_transition_session); } diff --git a/src/hooks/protections/invalid_decal.cpp b/src/hooks/protections/invalid_decal.cpp index 75281647..cb4423ec 100644 --- a/src/hooks/protections/invalid_decal.cpp +++ b/src/hooks/protections/invalid_decal.cpp @@ -4,11 +4,11 @@ namespace big { void hooks::invalid_decal(uintptr_t a1, int a2) { - if (a1 && a2 == 2) + if (a1 && a2 == 2) [[unlikely]] //*(*(*(a1 + 0x48) + 0x30) + 0x2C8) - if (const auto ptr = *reinterpret_cast((a1 + 0x48)); ptr) - if (const auto ptr2 = *reinterpret_cast((ptr + 0x30)); ptr2) - if (*reinterpret_cast(ptr2 + 0x2C8) == 0) + if (const auto ptr = *reinterpret_cast((a1 + 0x48)); ptr) [[unlikely]] + if (const auto ptr2 = *reinterpret_cast((ptr + 0x30)); ptr2) [[unlikely]] + if (*reinterpret_cast(ptr2 + 0x2C8) == 0) [[unlikely]] return; g_hooking->get_original()(a1, a2); diff --git a/src/hooks/protections/invalid_mods_crash_detour.cpp b/src/hooks/protections/invalid_mods_crash_detour.cpp index f997c271..0c76f8f1 100644 --- a/src/hooks/protections/invalid_mods_crash_detour.cpp +++ b/src/hooks/protections/invalid_mods_crash_detour.cpp @@ -4,7 +4,7 @@ namespace big { void hooks::invalid_mods_crash_detour(int64_t a1, int64_t a2, int a3, char a4) { - if (!*(int64_t*)(a1 + 0xD8)) + if (!*(int64_t*)(a1 + 0xD8)) [[unlikely]] return; g_hooking->get_original()(a1, a2, a3, a4); } diff --git a/src/hooks/protections/received_clone_create.cpp b/src/hooks/protections/received_clone_create.cpp index 527988ae..d4e1556d 100644 --- a/src/hooks/protections/received_clone_create.cpp +++ b/src/hooks/protections/received_clone_create.cpp @@ -6,7 +6,7 @@ namespace big { void hooks::received_clone_create(CNetworkObjectMgr* mgr, CNetGamePlayer* src, CNetGamePlayer* dst, eNetObjType object_type, int32_t object_id, int32_t object_flag, rage::datBitBuffer* buffer, int32_t timestamp) { - if (object_type < eNetObjType::NET_OBJ_TYPE_AUTOMOBILE || object_type > eNetObjType::NET_OBJ_TYPE_TRAIN) + if (object_type < eNetObjType::NET_OBJ_TYPE_AUTOMOBILE || object_type > eNetObjType::NET_OBJ_TYPE_TRAIN) [[unlikely]] { notify::crash_blocked(src, "out of bounds object type"); return; @@ -14,14 +14,14 @@ namespace big auto plyr = g_player_service->get_by_id(src->m_player_id); - if (plyr && plyr->block_clone_create) + if (plyr && plyr->block_clone_create) [[unlikely]] return; g.m_syncing_player = src; g.m_syncing_object_type = object_type; g.debug.fuzzer.thread_id = GetCurrentThreadId(); - if (g.debug.fuzzer.enabled_object_types[(int)object_type]) + if (g.debug.fuzzer.enabled_object_types[(int)object_type]) [[unlikely]] g.debug.fuzzer.active = true; g.debug.fuzzer.syncing_object_id = object_id; g_hooking->get_original()(mgr, src, dst, object_type, object_id, object_flag, buffer, timestamp); diff --git a/src/hooks/protections/received_clone_remove.cpp b/src/hooks/protections/received_clone_remove.cpp index e7d4ab23..e865a6e1 100644 --- a/src/hooks/protections/received_clone_remove.cpp +++ b/src/hooks/protections/received_clone_remove.cpp @@ -5,7 +5,7 @@ namespace big { void hooks::received_clone_remove(CNetworkObjectMgr* mgr, CNetGamePlayer* src, CNetGamePlayer* dst, int16_t object_id, uint32_t ownership_token) { - if (dst->m_player_info->m_ped->m_net_object->m_object_id == object_id) + if (dst->m_player_info->m_ped->m_net_object->m_object_id == object_id) [[unlikely]] { notify::crash_blocked(src, "player ped removal"); return; diff --git a/src/hooks/protections/received_clone_sync.cpp b/src/hooks/protections/received_clone_sync.cpp index 2890c294..211db247 100644 --- a/src/hooks/protections/received_clone_sync.cpp +++ b/src/hooks/protections/received_clone_sync.cpp @@ -6,13 +6,13 @@ namespace big { eAckCode hooks::received_clone_sync(CNetworkObjectMgr* mgr, CNetGamePlayer* src, CNetGamePlayer* dst, eNetObjType object_type, uint16_t object_id, rage::datBitBuffer* buffer, uint16_t unk, uint32_t timestamp) { - if (object_type < eNetObjType::NET_OBJ_TYPE_AUTOMOBILE || object_type > eNetObjType::NET_OBJ_TYPE_TRAIN) + if (object_type < eNetObjType::NET_OBJ_TYPE_AUTOMOBILE || object_type > eNetObjType::NET_OBJ_TYPE_TRAIN) [[unlikely]] { notify::crash_blocked(src, "out of bounds object type"); return eAckCode::ACKCODE_FAIL; } - if (auto net_obj = g_pointers->m_gta.m_get_net_object(mgr, object_id, true); net_obj && net_obj->m_object_type != (int16_t)object_type) + if (auto net_obj = g_pointers->m_gta.m_get_net_object(mgr, object_id, true); net_obj && net_obj->m_object_type != (int16_t)object_type) [[unlikely]] { notify::crash_blocked(src, "incorrect object type"); return eAckCode::ACKCODE_FAIL; @@ -20,14 +20,14 @@ namespace big auto plyr = g_player_service->get_by_id(src->m_player_id); - if (plyr && plyr->block_clone_sync) + if (plyr && plyr->block_clone_sync) [[unlikely]] return eAckCode::ACKCODE_FAIL; g.m_syncing_player = src; g.m_syncing_object_type = object_type; g.debug.fuzzer.thread_id = GetCurrentThreadId(); - if (g.debug.fuzzer.enabled_object_types[(int)object_type]) + if (g.debug.fuzzer.enabled_object_types[(int)object_type]) [[unlikely]] g.debug.fuzzer.active = true; g.debug.fuzzer.syncing_object_id = object_id; auto ret = g_hooking->get_original()(mgr, src, dst, object_type, object_id, buffer, unk, timestamp); diff --git a/src/hooks/protections/received_event.cpp b/src/hooks/protections/received_event.cpp index 2e63ac01..7a3c812b 100644 --- a/src/hooks/protections/received_event.cpp +++ b/src/hooks/protections/received_event.cpp @@ -378,14 +378,14 @@ namespace big void hooks::received_event(rage::netEventMgr* event_manager, CNetGamePlayer* source_player, CNetGamePlayer* target_player, uint16_t event_id, int event_index, int event_handled_bitset, int buffer_size, rage::datBitBuffer* buffer) { - if (event_id > 91u) + if (event_id > 91u) [[unlikely]] { g_pointers->m_gta.m_send_event_ack(event_manager, source_player, target_player, event_index, event_handled_bitset); return; } const auto event_name = *(char**)((DWORD64)event_manager + 8i64 * event_id + 243376); - if (event_name == nullptr || source_player == nullptr || source_player->m_player_id < 0 || source_player->m_player_id >= 32) + if (event_name == nullptr || source_player == nullptr || source_player->m_player_id < 0 || source_player->m_player_id >= 32) [[unlikely]] { g_pointers->m_gta.m_send_event_ack(event_manager, source_player, target_player, event_index, event_handled_bitset); return; @@ -393,7 +393,7 @@ namespace big auto plyr = g_player_service->get_by_id(source_player->m_player_id); - if (plyr && plyr->block_net_events) + if (plyr && plyr->block_net_events) [[unlikely]] { g_pointers->m_gta.m_send_event_ack(event_manager, source_player, target_player, event_index, event_handled_bitset); return; diff --git a/src/hooks/protections/render_big_ped.cpp b/src/hooks/protections/render_big_ped.cpp index bbfa8327..80df2f3e 100644 --- a/src/hooks/protections/render_big_ped.cpp +++ b/src/hooks/protections/render_big_ped.cpp @@ -5,12 +5,12 @@ namespace big { __int64 hooks::render_big_ped(__int64 renderer, CPed* ped, __int64 a3, __int64 a4) { - if (*(int*)(((__int64)(*g_pointers->m_gta.m_draw_handler_mgr) + 0x14730)) >= 512) + if (*(int*)(((__int64)(*g_pointers->m_gta.m_draw_handler_mgr) + 0x14730)) >= 512) [[unlikely]] { *(int*)(a4 + 4) = -2; return a4 + 0x14; } - else + else [[likely]] { return g_hooking->get_original()(renderer, ped, a3, a4); } diff --git a/src/hooks/protections/render_entity.cpp b/src/hooks/protections/render_entity.cpp index 43dfadec..56700993 100644 --- a/src/hooks/protections/render_entity.cpp +++ b/src/hooks/protections/render_entity.cpp @@ -5,14 +5,14 @@ namespace big { void hooks::render_entity(__int64 renderer, rage::fwEntity* entity, int unk, bool a4) { - if (*(int*)(((__int64)(*g_pointers->m_gta.m_draw_handler_mgr) + 0x14730)) >= 512) + if (*(int*)(((__int64)(*g_pointers->m_gta.m_draw_handler_mgr) + 0x14730)) >= 512) [[unlikely]] { *(int*)(renderer + 4) &= ~0x80000000; *(int*)(renderer + 4) &= ~0x40000000; *(int*)(renderer + 4) |= (a4 & 1) << 30; *(int*)renderer = -2; } - else + else [[likely]] { g_hooking->get_original()(renderer, entity, unk, a4); } diff --git a/src/hooks/protections/render_ped.cpp b/src/hooks/protections/render_ped.cpp index 1a84a94c..65bba030 100644 --- a/src/hooks/protections/render_ped.cpp +++ b/src/hooks/protections/render_ped.cpp @@ -5,11 +5,11 @@ namespace big { void* hooks::render_ped(__int64 renderer, CPed* ped, __int64 a3, __int64 a4) { - if (*(int*)(((__int64)(*g_pointers->m_gta.m_draw_handler_mgr) + 0x14730)) >= 499) + if (*(int*)(((__int64)(*g_pointers->m_gta.m_draw_handler_mgr) + 0x14730)) >= 499) [[unlikely]] { return nullptr; } - else + else [[likely]] { return g_hooking->get_original()(renderer, ped, a3, a4); } diff --git a/src/hooks/protections/serialize_parachute_task.cpp b/src/hooks/protections/serialize_parachute_task.cpp index 21ccadf7..778371b5 100644 --- a/src/hooks/protections/serialize_parachute_task.cpp +++ b/src/hooks/protections/serialize_parachute_task.cpp @@ -18,7 +18,7 @@ namespace big auto object = reinterpret_cast(info + 0x30); g_hooking->get_original()(info, serializer); - if (object->m_entity && object->m_entity->m_entity_type != 5) + if (object->m_entity && object->m_entity->m_entity_type != 5) [[unlikely]] { g_pointers->m_gta.m_remove_reference(object->m_entity, &object->m_entity); notify::crash_blocked(g.m_syncing_player, "invalid parachute object type"); diff --git a/src/hooks/protections/serialize_take_off_ped_variation_task.cpp b/src/hooks/protections/serialize_take_off_ped_variation_task.cpp index 054b70fc..9ff59b15 100644 --- a/src/hooks/protections/serialize_take_off_ped_variation_task.cpp +++ b/src/hooks/protections/serialize_take_off_ped_variation_task.cpp @@ -28,7 +28,7 @@ namespace big void hooks::serialize_take_off_ped_variation_task(ClonedTakeOffPedVariationInfo* info, rage::CSyncDataBase* serializer) { g_hooking->get_original()(info, serializer); - if (!is_valid_parachute_model(info->m_prop_hash)) + if (!is_valid_parachute_model(info->m_prop_hash)) [[unlikely]] { notify::crash_blocked(g.m_syncing_player, "invalid parachute model"); info->m_prop_hash = 0; diff --git a/src/hooks/protections/task_ambient_clips.cpp b/src/hooks/protections/task_ambient_clips.cpp index 1b4745a6..8e8476d6 100644 --- a/src/hooks/protections/task_ambient_clips.cpp +++ b/src/hooks/protections/task_ambient_clips.cpp @@ -7,7 +7,7 @@ namespace big // enter crash func // TODO: this doesn't block the crash completely - if (*(uint64_t*)(_this + 0x100)) + if (*(uint64_t*)(_this + 0x100)) [[likely]] return g_hooking->get_original()(_this, a2, a3); return 0; diff --git a/src/hooks/protections/task_parachute_object.cpp b/src/hooks/protections/task_parachute_object.cpp index 08f961ec..f1644fcc 100644 --- a/src/hooks/protections/task_parachute_object.cpp +++ b/src/hooks/protections/task_parachute_object.cpp @@ -4,11 +4,11 @@ namespace big { int hooks::task_parachute_object(uint64_t _this, int a2, int a3) { - if (a2 == 1 && a3 == 1) // enter crash func + if (a2 == 1 && a3 == 1) // enter crash func { - if (auto ptr = *(uint64_t*)(_this + 16)) - if (auto ptr2 = *(uint64_t*)(ptr + 80)) - if (auto ptr3 = *(uint64_t*)(ptr2 + 64)) + if (auto ptr = *(uint64_t*)(_this + 16)) [[likely]] + if (auto ptr2 = *(uint64_t*)(ptr + 80)) [[likely]] + if (auto ptr3 = *(uint64_t*)(ptr2 + 64)) [[likely]] return g_hooking->get_original()(_this, a2, a3); return 0; } diff --git a/src/hooks/script/run_script_threads.cpp b/src/hooks/script/run_script_threads.cpp index 77f43b96..58dc9bde 100644 --- a/src/hooks/script/run_script_threads.cpp +++ b/src/hooks/script/run_script_threads.cpp @@ -5,7 +5,7 @@ namespace big { bool hooks::run_script_threads(uint32_t ops_to_execute) { - if (g_running) + if (g_running) [[likely]] { g_script_mgr.tick(); } diff --git a/src/invoker/invoker.hpp b/src/invoker/invoker.hpp index 849f7e6c..04f71ed9 100644 --- a/src/invoker/invoker.hpp +++ b/src/invoker/invoker.hpp @@ -33,16 +33,17 @@ namespace big m_call_context.reset(); } - template + template constexpr void end_call() { // TODO: try to get rid of this - if (!m_are_handlers_cached) + [[assume((cache_handlers(), m_are_handlers_cached == true))]]; + if (!m_are_handlers_cached) [[unlikely]] cache_handlers(); m_handlers[index](&m_call_context); - if constexpr (fix_vectors) - this->fix_vectors(); + if constexpr (should_fix_vectors) + fix_vectors(); } template @@ -64,7 +65,8 @@ namespace big static rage::scrNativeHandler* get_handlers() { - if (!m_are_handlers_cached) + [[assume((cache_handlers(), m_are_handlers_cached == true))]]; + if (!m_are_handlers_cached) [[unlikely]] cache_handlers(); return m_handlers; diff --git a/src/native_hooks/all_scripts.hpp b/src/native_hooks/all_scripts.hpp index f50a737c..3e944e7d 100644 --- a/src/native_hooks/all_scripts.hpp +++ b/src/native_hooks/all_scripts.hpp @@ -26,7 +26,7 @@ namespace big void NETWORK_SET_THIS_SCRIPT_IS_NETWORK_SCRIPT(rage::scrNativeCallContext* src) { - if (src->get_arg(2) != -1 && src->get_arg(2) >= 0x100) + if (src->get_arg(2) != -1 && src->get_arg(2) >= 0x100) [[unlikely]] { notify::crash_blocked(nullptr, "out of bounds instance id"); return; @@ -37,7 +37,7 @@ namespace big void NETWORK_TRY_TO_SET_THIS_SCRIPT_IS_NETWORK_SCRIPT(rage::scrNativeCallContext* src) { - if (src->get_arg(2) != -1 && src->get_arg(2) >= 0x100) + if (src->get_arg(2) != -1 && src->get_arg(2) >= 0x100) [[unlikely]] { notify::crash_blocked(nullptr, "out of bounds instance id"); src->set_return_value(FALSE); diff --git a/src/renderer/renderer.cpp b/src/renderer/renderer.cpp index 2568deb2..4a8de57d 100644 --- a/src/renderer/renderer.cpp +++ b/src/renderer/renderer.cpp @@ -75,13 +75,13 @@ namespace big void renderer::on_present() { - if (m_font_mgr.can_use()) + if (m_font_mgr.can_use()) [[likely]] { new_frame(); for (const auto& cb : m_dx_callbacks | std::views::values) cb(); end_frame(); - + m_font_mgr.release_use(); } } diff --git a/src/services/persist_weapons/persist_weapons.cpp b/src/services/persist_weapons/persist_weapons.cpp index aebd33f9..183ea065 100644 --- a/src/services/persist_weapons/persist_weapons.cpp +++ b/src/services/persist_weapons/persist_weapons.cpp @@ -83,7 +83,7 @@ namespace big persist_weapon_loadout = get_loadout(g.persist_weapons.weapon_loadout_file); } - if (g_local_player == nullptr || g_local_player->m_player_info == nullptr || g_local_player->m_player_info->m_game_state == eGameState::InMPCutscene || STREAMING::IS_PLAYER_SWITCH_IN_PROGRESS() || DLC::GET_IS_LOADING_SCREEN_ACTIVE()) + if (g_local_player == nullptr || g_local_player->m_player_info == nullptr || g_local_player->m_player_info->m_game_state == eGameState::InMPCutscene || STREAMING::IS_PLAYER_SWITCH_IN_PROGRESS() || DLC::GET_IS_LOADING_SCREEN_ACTIVE()) [[unlikely]] { return; } @@ -150,7 +150,7 @@ namespace big { Player player = self::id; Ped player_ped = self::ped; - if (PED::IS_PED_DEAD_OR_DYING(player_ped, true)) + if (PED::IS_PED_DEAD_OR_DYING(player_ped, true)) [[unlikely]] return; for (auto weapon : loadout.weapons) diff --git a/src/thread_pool.cpp b/src/thread_pool.cpp index 1d23d847..58350e41 100644 --- a/src/thread_pool.cpp +++ b/src/thread_pool.cpp @@ -51,7 +51,7 @@ namespace big std::unique_lock lock(m_lock); m_job_stack.push({func, location}); - if (m_allocated_thread_count - m_busy_threads < m_job_stack.size()) + if (m_allocated_thread_count - m_busy_threads < m_job_stack.size()) [[unlikely]] { LOG(WARNING) << "Thread pool potentially starved, resizing to accommodate for load."; @@ -79,9 +79,9 @@ namespace big return !m_job_stack.empty() || !m_accept_jobs; }); - if (!m_accept_jobs) + if (!m_accept_jobs) [[unlikely]] break; - if (m_job_stack.empty()) + if (m_job_stack.empty()) [[likely]] continue; thread_pool_job job = m_job_stack.top();