Skip to content

Commit 9d5f0ac

Browse files
committed
Inline constructor, rename sort
1 parent d898156 commit 9d5f0ac

File tree

5 files changed

+12
-44
lines changed

5 files changed

+12
-44
lines changed

src/chart/generator/plot.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ Plot::sortedBuckets(const Buckets &buckets, bool main)
201201
}
202202
}
203203

204-
if (main && options->sorted == Sort::byValue) {
204+
if (main && options->sort == Sort::byValue) {
205205
std::sort(sorted.begin(),
206206
sorted.end(),
207207
[=](const std::pair<uint64_t, double> &a,

src/chart/options/config.cpp

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -247,19 +247,7 @@ Config::Accessors Config::initAccessors()
247247

248248
res.emplace(accessor<&Options::title>);
249249
res.emplace(accessor<&Options::legend>);
250-
251-
res.insert({"coordSystem",
252-
{.get =
253-
[](const Options &options)
254-
{
255-
return Conv::toString(options.coordSystem);
256-
},
257-
.set =
258-
[](OptionsSetter &setter, const std::string &value)
259-
{
260-
setter.setCoordSystem(
261-
Conv::parse<CoordSystem>(value));
262-
}}});
250+
res.emplace(accessor<&Options::coordSystem>);
263251

264252
res.insert({"rotate",
265253
{.get =
@@ -292,18 +280,7 @@ Config::Accessors Config::initAccessors()
292280
orientation == Orientation::horizontal);
293281
}}});
294282

295-
res.insert({"sort",
296-
{.get =
297-
[](const Options &options)
298-
{
299-
return Conv::toString(options.sorted);
300-
},
301-
.set =
302-
[](OptionsSetter &setter, const std::string &value)
303-
{
304-
setter.setSorted(Conv::parse<Sort>(value));
305-
}}});
306-
283+
res.emplace(accessor<&Options::sort>);
307284
res.emplace(accessor<&Options::reverse>);
308285
res.emplace(accessor<&Options::align>);
309286
res.emplace(accessor<&Options::split>);

src/chart/options/options.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ ChannelExtrema operator"" _perc(long double percent)
1717

1818
uint64_t Options::nextMarkerInfoId = 1;
1919

20-
Options::Options() :
21-
title(std::nullopt),
22-
coordSystem(CoordSystem::cartesian),
23-
geometry(ShapeType::rectangle),
24-
horizontal(true),
25-
sorted(Sort::none),
26-
reverse(false)
27-
{}
28-
2920
void Options::reset()
3021
{
3122
channels.reset();
@@ -185,7 +176,7 @@ bool Options::sameShadowAttribs(const Options &other) const
185176
return shape == shapeOther && coordSystem == other.coordSystem
186177
&& angle == other.angle && horizontal == other.horizontal
187178
&& split == other.split && dataFilter == other.dataFilter
188-
&& align == other.align && sorted == other.sorted
179+
&& align == other.align && sort == other.sort
189180
&& reverse == other.reverse;
190181
}
191182

src/chart/options/options.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Options
3535
using Legend = ::Anim::Interpolated<LegendType>;
3636
using MarkersInfoMap = std::map<uint64_t, MarkerId>;
3737

38-
Options();
38+
Options() = default;
3939

4040
[[nodiscard]] const Channels &getChannels() const
4141
{
@@ -75,16 +75,16 @@ class Options
7575

7676
Channel &stackAxis() { return channels.at(stackAxisType()); }
7777

78-
Title title;
79-
Anim::Interpolated<CoordSystem> coordSystem;
78+
Title title{std::nullopt};
79+
Anim::Interpolated<CoordSystem> coordSystem{CoordSystem::cartesian};
8080
double angle;
81-
Anim::Interpolated<ShapeType> geometry;
82-
Math::FuzzyBool horizontal;
81+
Anim::Interpolated<ShapeType> geometry{ShapeType::rectangle};
82+
Math::FuzzyBool horizontal{true};
8383
Math::FuzzyBool split;
8484
Base::Align::Type align{Base::Align::Type::none};
8585
Data::Filter dataFilter;
86-
Sort sorted;
87-
Math::FuzzyBool reverse;
86+
Sort sort{Sort::none};
87+
Math::FuzzyBool reverse{false};
8888
Legend legend;
8989
std::optional<uint64_t> tooltip;
9090
MarkersInfoMap markersInfo;

src/chart/options/optionssetter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ OptionsSetter::setLabelLevel(const ChannelId &channelId, int level)
130130

131131
OptionsSetter &OptionsSetter::setSorted(Sort value)
132132
{
133-
options.sorted = value;
133+
options.sort = value;
134134
return *this;
135135
}
136136

0 commit comments

Comments
 (0)