Skip to content

Commit ed85cea

Browse files
committed
early bail out for enum functions
- separated from #1568, simple and verified approach to improve performance - there're some recent pull requests related to this, so I push it first
1 parent 084fcb6 commit ed85cea

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Utilities/EnumFunctions.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
bool EnumFunctions::CanTargetHouse(AffectedHouse flags, HouseClass* ownerHouse, HouseClass* targetHouse)
44
{
5+
if (flags == AffectedHouse::All)
6+
return true;
57
if (ownerHouse == targetHouse)
68
return (flags & AffectedHouse::Owner) != AffectedHouse::None;
79
if (ownerHouse->IsAlliedWith(targetHouse))
@@ -11,6 +13,9 @@ bool EnumFunctions::CanTargetHouse(AffectedHouse flags, HouseClass* ownerHouse,
1113

1214
bool EnumFunctions::IsCellEligible(CellClass* const pCell, AffectedTarget allowed, bool explicitEmptyCells, bool considerBridgesLand)
1315
{
16+
if (allowed == AffectedTarget::All)
17+
return true;
18+
1419
if (explicitEmptyCells)
1520
{
1621
auto pTechno = pCell->GetContent() ? abstract_cast<TechnoClass*>(pCell->GetContent()) : nullptr;
@@ -32,6 +37,9 @@ bool EnumFunctions::IsCellEligible(CellClass* const pCell, AffectedTarget allowe
3237

3338
bool EnumFunctions::IsTechnoEligible(TechnoClass* const pTechno, AffectedTarget allowed, bool considerAircraftSeparately)
3439
{
40+
if (allowed == AffectedTarget::All)
41+
return true;
42+
3543
if (allowed & AffectedTarget::AllContents)
3644
{
3745
if (pTechno)

0 commit comments

Comments
 (0)