From 5c912ffad96c21c6836e89d2d73bc02c1871a5fa Mon Sep 17 00:00:00 2001 From: mfranz Date: Fri, 20 Jul 2007 14:46:45 +0000 Subject: [PATCH] remove redundant if check in cases of if (foo) delete foo; The C++ standard explicitly allows deleting a null pointer. --- src/AIModel/AIFlightPlan.cxx | 6 ++---- src/AIModel/AIFlightPlanCreate.cxx | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/AIModel/AIFlightPlan.cxx b/src/AIModel/AIFlightPlan.cxx index 362604be2..48af6afb8 100644 --- a/src/AIModel/AIFlightPlan.cxx +++ b/src/AIModel/AIFlightPlan.cxx @@ -298,8 +298,7 @@ FGAIFlightPlan::FGAIFlightPlan(const std::string& p, FGAIFlightPlan::~FGAIFlightPlan() { deleteWaypoints(); - if (taxiRoute) - delete taxiRoute; + delete taxiRoute; } @@ -492,8 +491,7 @@ void FGAIFlightPlan::restart() void FGAIFlightPlan::deleteTaxiRoute() { - if (taxiRoute) - delete taxiRoute; + delete taxiRoute; taxiRoute = 0; } diff --git a/src/AIModel/AIFlightPlanCreate.cxx b/src/AIModel/AIFlightPlanCreate.cxx index ea476a8f6..d615f4b54 100644 --- a/src/AIModel/AIFlightPlanCreate.cxx +++ b/src/AIModel/AIFlightPlanCreate.cxx @@ -257,8 +257,7 @@ void FGAIFlightPlan::createTaxi(bool firstFlight, int direction, // Starting from gate 0 in this case is a bit of a hack // which requires a more proper solution later on. //FGTaxiRoute route; - if (taxiRoute) - delete taxiRoute; + delete taxiRoute; taxiRoute = new FGTaxiRoute; if (gateId >= 0) *taxiRoute = apt->getDynamics()->getGroundNetwork()->findShortestRoute(gateId, @@ -427,8 +426,7 @@ void FGAIFlightPlan::createTaxi(bool firstFlight, int direction, // fallback mechanism for this. // Starting from gate 0 is a bit of a hack... //FGTaxiRoute route; - if (taxiRoute) - delete taxiRoute; + delete taxiRoute; taxiRoute = new FGTaxiRoute; if (gateId >= 0) *taxiRoute = apt->getDynamics()->getGroundNetwork()->findShortestRoute(runwayId, -- 2.39.5