Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove most VLOG and a function and a macro that now have no purpose #1519

Merged
merged 2 commits into from
Aug 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions base/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 12 additions & 38 deletions ksp_plugin/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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<Celestial const*> parent =
FindOrDie(celestials_, parent_index).get();
Expand Down Expand Up @@ -373,8 +367,7 @@ void Plugin::InsertUnloadedPart(
std::string const& name,
GUID const& vessel_guid,
RelativeDegreesOfFreedom<AliceSun> const& from_parent) {
not_null<Vessel*> const vessel =
find_vessel_by_guid_or_die(vessel_guid).get();
not_null<Vessel*> const vessel = FindOrDie(vessels_, vessel_guid).get();
RelativeDegreesOfFreedom<Barycentric> const relative =
PlanetariumRotation().Inverse()(from_parent);
ephemeris_->Prolong(current_time_);
Expand All @@ -397,8 +390,7 @@ void Plugin::InsertOrKeepLoadedPart(
DegreesOfFreedom<World> const& main_body_degrees_of_freedom,
DegreesOfFreedom<World> const& part_degrees_of_freedom,
Time const& Δt) {
not_null<Vessel*> const vessel =
find_vessel_by_guid_or_die(vessel_guid).get();
not_null<Vessel*> const vessel = FindOrDie(vessels_, vessel_guid).get();
CHECK(is_loaded(vessel));

auto it = part_id_to_vessel_.find(part_id);
Expand Down Expand Up @@ -597,8 +589,6 @@ DegreesOfFreedom<World> 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_);

Expand All @@ -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();
Expand All @@ -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
Expand Down Expand Up @@ -649,7 +636,7 @@ RelativeDegreesOfFreedom<AliceSun> Plugin::VesselFromParent(
GUID const& vessel_guid) const {
CHECK(!initializing_);
not_null<std::unique_ptr<Vessel>> const& vessel =
find_vessel_by_guid_or_die(vessel_guid);
FindOrDie(vessels_, vessel_guid);
not_null<Celestial const*> parent =
FindOrDie(celestials_, parent_index).get();
if (vessel->parent() != parent) {
Expand All @@ -660,9 +647,6 @@ RelativeDegreesOfFreedom<AliceSun> Plugin::VesselFromParent(
vessel->parent()->current_degrees_of_freedom(current_time_);
RelativeDegreesOfFreedom<AliceSun> const result =
PlanetariumRotation()(barycentric_result);
VLOG(1) << "Vessel " << vessel->ShortDebugString()
<< " is at parent degrees of freedom + " << barycentric_result
<< " Barycentre (" << result << " AliceSun)";
return result;
}

Expand All @@ -678,23 +662,20 @@ RelativeDegreesOfFreedom<AliceSun> Plugin::CelestialFromParent(
celestial.parent()->current_degrees_of_freedom(current_time_);
RelativeDegreesOfFreedom<AliceSun> 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_);
}

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_);
Expand Down Expand Up @@ -806,7 +787,7 @@ bool Plugin::HasVessel(GUID const& vessel_guid) const {

not_null<Vessel*> 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<std::unique_ptr<Planetarium>> Plugin::NewPlanetarium(
Expand Down Expand Up @@ -876,8 +857,7 @@ void Plugin::SetTargetVessel(GUID const& vessel_guid,
Index const reference_body_index) {
not_null<Celestial const*> const celestial =
FindOrDie(celestials_, reference_body_index).get();
not_null<Vessel*> const vessel =
find_vessel_by_guid_or_die(vessel_guid).get();
not_null<Vessel*> 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_);
Expand Down Expand Up @@ -985,19 +965,19 @@ std::unique_ptr<FrameField<World, Navball>> Plugin::NavballFrameField(

Vector<double, World> Plugin::VesselTangent(GUID const& vessel_guid) const {
return renderer_->FrenetToWorld(
*find_vessel_by_guid_or_die(vessel_guid),
*FindOrDie(vessels_, vessel_guid),
PlanetariumRotation())(Vector<double, Frenet<Navigation>>({1, 0, 0}));
}

Vector<double, World> Plugin::VesselNormal(GUID const& vessel_guid) const {
return renderer_->FrenetToWorld(
*find_vessel_by_guid_or_die(vessel_guid),
*FindOrDie(vessels_, vessel_guid),
PlanetariumRotation())(Vector<double, Frenet<Navigation>>({0, 1, 0}));
}

Vector<double, World> Plugin::VesselBinormal(GUID const& vessel_guid) const {
return renderer_->FrenetToWorld(
*find_vessel_by_guid_or_die(vessel_guid),
*FindOrDie(vessels_, vessel_guid),
PlanetariumRotation())(Vector<double, Frenet<Navigation>>({0, 0, 1}));
}

Expand All @@ -1014,7 +994,7 @@ Velocity<World> Plugin::UnmanageableVesselVelocity(
}

Velocity<World> 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());
}
Expand Down Expand Up @@ -1234,12 +1214,6 @@ void Plugin::InitializeIndices(
CHECK(inserted) << celestial_index;
}

not_null<std::unique_ptr<Vessel>> 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
Expand Down
3 changes: 0 additions & 3 deletions ksp_plugin/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,6 @@ class Plugin {
Index celestial_index,
std::experimental::optional<Index> const& parent_index);

not_null<std::unique_ptr<Vessel>> 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();
Expand Down
2 changes: 0 additions & 2 deletions ksp_plugin/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 0 additions & 4 deletions physics/ephemeris_body.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,6 @@ Ephemeris<Frame>::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));
Expand Down Expand Up @@ -522,7 +519,6 @@ template<typename Frame>
void Ephemeris<Frame>::FlowWithFixedStep(
Instant const& t,
typename Integrator<NewtonianMotionEquation>::Instance& instance) {
VLOG(1) << __FUNCTION__ << " " << NAMED(t);
if (empty() || t > t_max()) {
Prolong(t);
}
Expand Down