Commit 15b2a486 authored by Max Kellermann's avatar Max Kellermann

protocol/RangeArg: add Contains()

parent 2915d2dd
...@@ -202,9 +202,7 @@ db_selection_print(Response &r, Partition &partition, ...@@ -202,9 +202,7 @@ db_selection_print(Response &r, Partition &partition,
if (sort == TAG_NUM_OF_ITEM_TYPES) { if (sort == TAG_NUM_OF_ITEM_TYPES) {
if (!window.IsAll()) if (!window.IsAll())
s = [s, window, &i](const LightSong &song){ s = [s, window, &i](const LightSong &song){
const bool in_window = i >= window.start && i < window.end; if (window.Contains(i++))
++i;
if (in_window)
s(song); s(song);
}; };
......
...@@ -42,6 +42,10 @@ struct RangeArg { ...@@ -42,6 +42,10 @@ struct RangeArg {
constexpr bool IsAll() const noexcept { constexpr bool IsAll() const noexcept {
return *this == All(); return *this == All();
} }
constexpr bool Contains(unsigned i) const noexcept {
return i >= start && i < end;
}
}; };
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment