From: mfranz Date: Fri, 20 Jul 2007 14:46:45 +0000 (+0000) Subject: remove redundant if check in cases of if (foo) delete foo; X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5c912ffad96c21c6836e89d2d73bc02c1871a5fa;p=flightgear.git remove redundant if check in cases of if (foo) delete foo; The C++ standard explicitly allows deleting a null pointer. --- 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,