Skip to content

Commit

Permalink
Some micro-opt + size opt
Browse files Browse the repository at this point in the history
  • Loading branch information
schaumb committed Apr 30, 2024
1 parent d4cc999 commit d48b677
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 35 deletions.
13 changes: 5 additions & 8 deletions src/chart/animator/keyframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,16 @@ void Keyframe::addMissingMarkers(const Gen::PlotPtr &source,
{
for (auto i = source->getMarkers().size();
i < target->getMarkers().size();
++i) {
auto src = target->getMarkers()[i];
src.enabled = false;
source->markers.push_back(src);
}
++i)
source->markers.emplace_back(target->getMarkers()[i])
.enabled = false;

for (auto i = target->getMarkers().size();
i < source->getMarkers().size();
++i) {
if (withTargetCopying) copyTarget();
auto trg = source->getMarkers()[i];
trg.enabled = false;
target->markers.push_back(trg);
target->markers.emplace_back(source->getMarkers()[i])
.enabled = false;
}
}

Expand Down
52 changes: 28 additions & 24 deletions src/chart/animator/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,21 @@ void Planner::calcNeeded()
&& static_cast<bool>(trgOpt->legend.get())
&& (*srcOpt->legend.get() != *trgOpt->legend.get()));

animNeeded[SectionId::show] = anyMarker(
[&](const auto &source, const auto &target)
{
return static_cast<bool>(
!source.enabled && target.enabled);
});

animNeeded[SectionId::hide] = anyMarker(
[&](const auto &source, const auto &target)
{
return static_cast<bool>(
source.enabled && !target.enabled);
});
animNeeded[SectionId::show] =
anyMarker(+[](const Gen::Marker &source,
const Gen::Marker &target) -> bool
{
return static_cast<bool>(
!source.enabled && target.enabled);
});

animNeeded[SectionId::hide] =
anyMarker(+[](const Gen::Marker &source,
const Gen::Marker &target) -> bool
{
return static_cast<bool>(
source.enabled && !target.enabled);
});

animNeeded[SectionId::color] = needColor();

Expand All @@ -285,19 +287,19 @@ void Planner::calcNeeded()
animNeeded[SectionId::x] = needHorizontal();

animNeeded[SectionId::connection] =
anyMarker(
[&](const auto &source, const auto &target)
anyMarker(+[](const Gen::Marker &source,
const Gen::Marker &target) -> bool
{
return static_cast<bool>(
source.prevMainMarkerIdx
return source.prevMainMarkerIdx
!= target.prevMainMarkerIdx
|| source.mainId != target.mainId);
|| source.mainId != target.mainId;
})
|| srcOpt->isHorizontal() != trgOpt->isHorizontal();
}

bool Planner::anyMarker(const std::function<bool(const Gen::Marker &,
const Gen::Marker &)> &compare) const
bool Planner::anyMarker(
std::function<bool(const Gen::Marker &, const Gen::Marker &)>
&&compare) const
{
for (auto i = 0U; i < source->getMarkers().size()
&& i < target->getMarkers().size();
Expand Down Expand Up @@ -350,7 +352,8 @@ bool Planner::needColor() const
!= target->measureAxises.at(
Gen::ChannelId::lightness)))
|| anyMarker(
[&](const auto &source, const auto &target)
[](const Gen::Marker &source,
const Gen::Marker &target) -> bool
{
return (source.enabled || target.enabled)
&& source.colorBase != target.colorBase;
Expand Down Expand Up @@ -419,8 +422,8 @@ bool Planner::needVertical() const
|| (target->markerConnectionOrientation.value_or(
Gen::Orientation::horizontal)
== Gen::Orientation::vertical)))
|| anyMarker(
[&](const auto &source, const auto &target)
|| anyMarker(+[](const Gen::Marker &source,
const Gen::Marker &target) -> bool
{
return (source.enabled || target.enabled)
&& (source.position.y != target.position.y
Expand Down Expand Up @@ -452,7 +455,8 @@ bool Planner::needHorizontal() const
Gen::Orientation::vertical)
== Gen::Orientation::horizontal)))
|| anyMarker(
[&](const auto &source, const auto &target)
[](const Gen::Marker &source,
const Gen::Marker &target) -> bool
{
return (source.enabled || target.enabled)
&& (source.position.x != target.position.x
Expand Down
5 changes: 3 additions & 2 deletions src/chart/animator/planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ class Planner : public ::Anim::Group
::Anim::Duration delay = ::Anim::Duration(0),
const std::optional<::Anim::Easing> &easing = std::nullopt);

bool anyMarker(const std::function<bool(const Gen::Marker &,
const Gen::Marker &)> &compare) const;
bool anyMarker(
std::function<bool(const Gen::Marker &, const Gen::Marker &)>
&&compare) const;

[[nodiscard]] bool positionMorphNeeded() const;
[[nodiscard]] bool verticalBeforeHorizontal() const;
Expand Down
2 changes: 1 addition & 1 deletion src/dataframe/old/datatable.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DataCube
{
std::string_view name;
std::span<const std::string> categories;
std::size_t size;
std::size_t size{};
};
std::vector<DimensionInfo> dim_reindex;

Expand Down

0 comments on commit d48b677

Please sign in to comment.