From c2fb45efd3729428ccab7c0e64788e2947ec8ee8 Mon Sep 17 00:00:00 2001 From: pleroy Date: Thu, 10 Aug 2017 19:35:32 +0200 Subject: [PATCH 1/2] Remove most VLOG and a function and a macro that now have no purpose. --- base/macros.hpp | 7 ----- ksp_plugin/plugin.cpp | 52 ++++++++++---------------------------- ksp_plugin/plugin.hpp | 3 --- ksp_plugin/renderer.cpp | 2 -- physics/ephemeris_body.hpp | 4 --- 5 files changed, 13 insertions(+), 55 deletions(-) diff --git a/base/macros.hpp b/base/macros.hpp index aa9e45b772..6c7a328ae5 100644 --- a/base/macros.hpp +++ b/base/macros.hpp @@ -152,13 +152,6 @@ inline void noreturn() { std::exit(0); } # define GUARDED_BY(x) #endif -#define VLOG_AND_RETURN(verboselevel, expression) \ - do { \ - auto const& value__ = (expression); \ - VLOG(verboselevel) << __FUNCTION__ << " returns " << value__; \ - return value__; \ - } while (false) - // Unicode. #if OS_WIN # define UNICODE_PATH(x) u ## x diff --git a/ksp_plugin/plugin.cpp b/ksp_plugin/plugin.cpp index 4b26cf4619..8a52c9a5ad 100644 --- a/ksp_plugin/plugin.cpp +++ b/ksp_plugin/plugin.cpp @@ -268,8 +268,6 @@ bool Plugin::HasEncounteredApocalypse(std::string* const details) const { void Plugin::UpdateCelestialHierarchy(Index const celestial_index, Index const parent_index) const { - VLOG(1) << __FUNCTION__ << '\n' - << NAMED(celestial_index) << '\n' << NAMED(parent_index); CHECK(!initializing_); FindOrDie(celestials_, celestial_index)->set_parent( FindOrDie(celestials_, parent_index).get()); @@ -334,10 +332,6 @@ void Plugin::InsertOrKeepVessel(GUID const& vessel_guid, Index const parent_index, bool const loaded, bool& inserted) { - VLOG(1) << __FUNCTION__ << '\n' - << NAMED(vessel_guid) << '\n' - << NAMED(parent_index) << '\n' - << NAMED(loaded) << '\n'; CHECK(!initializing_); not_null parent = FindOrDie(celestials_, parent_index).get(); @@ -373,8 +367,7 @@ void Plugin::InsertUnloadedPart( std::string const& name, GUID const& vessel_guid, RelativeDegreesOfFreedom const& from_parent) { - not_null const vessel = - find_vessel_by_guid_or_die(vessel_guid).get(); + not_null const vessel = FindOrDie(vessels_, vessel_guid).get(); RelativeDegreesOfFreedom const relative = PlanetariumRotation().Inverse()(from_parent); ephemeris_->Prolong(current_time_); @@ -397,8 +390,7 @@ void Plugin::InsertOrKeepLoadedPart( DegreesOfFreedom const& main_body_degrees_of_freedom, DegreesOfFreedom const& part_degrees_of_freedom, Time const& Δt) { - not_null const vessel = - find_vessel_by_guid_or_die(vessel_guid).get(); + not_null const vessel = FindOrDie(vessels_, vessel_guid).get(); CHECK(is_loaded(vessel)); auto it = part_id_to_vessel_.find(part_id); @@ -597,8 +589,6 @@ DegreesOfFreedom Plugin::CelestialWorldDegreesOfFreedom( } void Plugin::AdvanceTime(Instant const& t, Angle const& planetarium_rotation) { - VLOG(1) << __FUNCTION__ << '\n' - << NAMED(t) << '\n' << NAMED(planetarium_rotation); CHECK(!initializing_); CHECK_GT(t, current_time_); @@ -607,9 +597,6 @@ void Plugin::AdvanceTime(Instant const& t, Angle const& planetarium_rotation) { } ephemeris_->Prolong(current_time_); - VLOG(1) << "Time has been advanced" << '\n' - << "from : " << current_time_ << '\n' - << "to : " << t; current_time_ = t; planetarium_rotation_ = planetarium_rotation; UpdatePlanetariumRotation(); @@ -618,7 +605,7 @@ void Plugin::AdvanceTime(Instant const& t, Angle const& planetarium_rotation) { void Plugin::CatchUpVessel(GUID const& vessel_guid) { CHECK(!initializing_); - Vessel& vessel = *find_vessel_by_guid_or_die(vessel_guid); + Vessel& vessel = *FindOrDie(vessels_, vessel_guid); vessel.ForSomePart([this](Part& part) { auto const pile_up = part.containing_pile_up()->iterator(); // This may be false, if we have already caught up the pile up as part of @@ -648,8 +635,8 @@ RelativeDegreesOfFreedom Plugin::VesselFromParent( Index const parent_index, GUID const& vessel_guid) const { CHECK(!initializing_); - not_null> const& vessel = - find_vessel_by_guid_or_die(vessel_guid); + not_null> const& vessel = + FindOrDie(vessels_, vessel_guid); not_null parent = FindOrDie(celestials_, parent_index).get(); if (vessel->parent() != parent) { @@ -660,9 +647,6 @@ RelativeDegreesOfFreedom Plugin::VesselFromParent( vessel->parent()->current_degrees_of_freedom(current_time_); RelativeDegreesOfFreedom const result = PlanetariumRotation()(barycentric_result); - VLOG(1) << "Vessel " << vessel->ShortDebugString() - << " is at parent degrees of freedom + " << barycentric_result - << " Barycentre (" << result << " AliceSun)"; return result; } @@ -678,15 +662,12 @@ RelativeDegreesOfFreedom Plugin::CelestialFromParent( celestial.parent()->current_degrees_of_freedom(current_time_); RelativeDegreesOfFreedom const result = PlanetariumRotation()(barycentric_result); - VLOG(1) << "Celestial at index " << celestial_index - << " is at parent degrees of freedom + " << barycentric_result - << " Barycentre (" << result << " AliceSun)"; return result; } void Plugin::UpdatePrediction(GUID const& vessel_guid) const { CHECK(!initializing_); - find_vessel_by_guid_or_die(vessel_guid)->UpdatePrediction( + FindOrDie(vessels_, vessel_guid)->UpdatePrediction( current_time_ + prediction_length_); } @@ -694,7 +675,7 @@ void Plugin::CreateFlightPlan(GUID const& vessel_guid, Instant const& final_time, Mass const& initial_mass) const { CHECK(!initializing_); - find_vessel_by_guid_or_die(vessel_guid)->CreateFlightPlan( + FindOrDie(vessels_, vessel_guid)->CreateFlightPlan( final_time, initial_mass, prediction_parameters_); @@ -806,7 +787,7 @@ bool Plugin::HasVessel(GUID const& vessel_guid) const { not_null Plugin::GetVessel(GUID const& vessel_guid) const { CHECK(!initializing_); - return find_vessel_by_guid_or_die(vessel_guid).get(); + return FindOrDie(vessels_, vessel_guid).get(); } not_null> Plugin::NewPlanetarium( @@ -876,8 +857,7 @@ void Plugin::SetTargetVessel(GUID const& vessel_guid, Index const reference_body_index) { not_null const celestial = FindOrDie(celestials_, reference_body_index).get(); - not_null const vessel = - find_vessel_by_guid_or_die(vessel_guid).get(); + not_null const vessel = FindOrDie(vessels_, vessel_guid).get(); // Make sure that the current time is covered by the prediction. if (current_time_ > vessel->prediction().t_max()) { vessel->UpdatePrediction(current_time_ + prediction_length_); @@ -985,19 +965,19 @@ std::unique_ptr> Plugin::NavballFrameField( Vector Plugin::VesselTangent(GUID const& vessel_guid) const { return renderer_->FrenetToWorld( - *find_vessel_by_guid_or_die(vessel_guid), + *FindOrDie(vessels_, vessel_guid), PlanetariumRotation())(Vector>({1, 0, 0})); } Vector Plugin::VesselNormal(GUID const& vessel_guid) const { return renderer_->FrenetToWorld( - *find_vessel_by_guid_or_die(vessel_guid), + *FindOrDie(vessels_, vessel_guid), PlanetariumRotation())(Vector>({0, 1, 0})); } Vector Plugin::VesselBinormal(GUID const& vessel_guid) const { return renderer_->FrenetToWorld( - *find_vessel_by_guid_or_die(vessel_guid), + *FindOrDie(vessels_, vessel_guid), PlanetariumRotation())(Vector>({0, 0, 1})); } @@ -1014,7 +994,7 @@ Velocity Plugin::UnmanageableVesselVelocity( } Velocity Plugin::VesselVelocity(GUID const& vessel_guid) const { - Vessel const& vessel = *find_vessel_by_guid_or_die(vessel_guid); + Vessel const& vessel = *FindOrDie(vessels_, vessel_guid); auto const& last = vessel.psychohistory().last(); return VesselVelocity(last.time(), last.degrees_of_freedom()); } @@ -1234,12 +1214,6 @@ void Plugin::InitializeIndices( CHECK(inserted) << celestial_index; } -not_null> const& Plugin::find_vessel_by_guid_or_die( - GUID const& vessel_guid) const { - VLOG(1) << __FUNCTION__ << '\n' << NAMED(vessel_guid); - VLOG_AND_RETURN(1, FindOrDie(vessels_, vessel_guid)); -} - void Plugin::UpdatePlanetariumRotation() { // The z axis of |PlanetariumFrame| is the pole of |main_body_|, and its x // axis is the origin of body rotation (the intersection between the diff --git a/ksp_plugin/plugin.hpp b/ksp_plugin/plugin.hpp index 8dd58991ca..6dfc37955e 100644 --- a/ksp_plugin/plugin.hpp +++ b/ksp_plugin/plugin.hpp @@ -395,9 +395,6 @@ class Plugin { Index celestial_index, std::experimental::optional const& parent_index); - not_null> const& find_vessel_by_guid_or_die( - GUID const& vessel_guid) const; - // Computes the value returned by |PlanetariumRotation|. Must be called // whenever |main_body_| or |planetarium_rotation_| changes. void UpdatePlanetariumRotation(); diff --git a/ksp_plugin/renderer.cpp b/ksp_plugin/renderer.cpp index db43160d6f..9b9ac39b1c 100644 --- a/ksp_plugin/renderer.cpp +++ b/ksp_plugin/renderer.cpp @@ -109,7 +109,6 @@ Renderer::RenderBarycentricTrajectoryInPlotting( it.time(), BarycentricToPlotting(it.time())(it.degrees_of_freedom())); } - VLOG(1) << "Returning a " << trajectory->Size() << "-point trajectory"; return trajectory; } @@ -154,7 +153,6 @@ Renderer::RenderPlottingTrajectoryInWorld( navigation_degrees_of_freedom.velocity())}; trajectory->Append(it.time(), world_degrees_of_freedom); } - VLOG(1) << "Returning a " << trajectory->Size() << "-point trajectory"; return trajectory; } diff --git a/physics/ephemeris_body.hpp b/physics/ephemeris_body.hpp index e644f065fc..8968fa6797 100644 --- a/physics/ephemeris_body.hpp +++ b/physics/ephemeris_body.hpp @@ -244,9 +244,6 @@ Ephemeris::Ephemeris( inserted.first->second.get(); CHECK_OK(trajectory->Append(initial_time, degrees_of_freedom)); - VLOG(1) << "Constructed trajectory " << trajectory - << " for body with mass " << body->mass(); - if (body->is_oblate()) { // Inserting at the beginning of the vectors is O(N). bodies_.insert(bodies_.begin(), std::move(body)); @@ -522,7 +519,6 @@ template void Ephemeris::FlowWithFixedStep( Instant const& t, typename Integrator::Instance& instance) { - VLOG(1) << __FUNCTION__ << " " << NAMED(t); if (empty() || t > t_max()) { Prolong(t); } From be398a1beb889ba48039f1e81b36b757b7e9c7a4 Mon Sep 17 00:00:00 2001 From: pleroy Date: Sat, 12 Aug 2017 10:09:25 +0200 Subject: [PATCH 2/2] Lint. --- ksp_plugin/plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ksp_plugin/plugin.cpp b/ksp_plugin/plugin.cpp index 8a52c9a5ad..4f0931467b 100644 --- a/ksp_plugin/plugin.cpp +++ b/ksp_plugin/plugin.cpp @@ -635,7 +635,7 @@ RelativeDegreesOfFreedom Plugin::VesselFromParent( Index const parent_index, GUID const& vessel_guid) const { CHECK(!initializing_); - not_null> const& vessel = + not_null> const& vessel = FindOrDie(vessels_, vessel_guid); not_null parent = FindOrDie(celestials_, parent_index).get();