fix(render): three warnings a stricter build reports, none of them behavioural
The point-index loop in `draw_traces` named its variable `i`, shadowing the trace index that the whole block is nested inside; it is `p` now, which also leaves the comment free to say which one is which. The marker loop's two screen coordinates were narrowed implicitly. And `same_cell()`'s only caller is an `assert`, so a release build had an unused function; it is guarded the way its caller is. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
c960decaea
commit
03c41adbec
2 files changed
+11
-6
No files matched your search
@@ -9,12 +9,17 @@
|
|||||||
namespace plot::render {
|
namespace plot::render {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
/// Two declared cells agree when neither size differs by more than the atlas'
|
/// Two declared cells agree when neither size differs by more than the atlas'
|
||||||
/// tolerance: the test `glyph_is_cell()` makes, for a cell against a cell.
|
/// tolerance: the test `glyph_is_cell()` makes, for a cell against a cell.
|
||||||
|
///
|
||||||
|
/// Guarded because its one caller is an `assert` (see `TextBatch::set_cell`), so a
|
||||||
|
/// release build has no use for it and would warn that it is unused.
|
||||||
bool same_cell(Vec2 a, Vec2 b) noexcept {
|
bool same_cell(Vec2 a, Vec2 b) noexcept {
|
||||||
const auto near = [](f32 p, f32 q) { return std::fabs(p - q) <= kAtlasCellTolerance; };
|
const auto near = [](f32 p, f32 q) { return std::fabs(p - q) <= kAtlasCellTolerance; };
|
||||||
return near(a.x, b.x) && near(a.y, b.y);
|
return near(a.x, b.x) && near(a.y, b.y);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/// `axis` as a unit vector: the cell's local +x, which is what the instance and
|
/// `axis` as a unit vector: the cell's local +x, which is what the instance and
|
||||||
/// the shader both take (see `TextInstance`). A zero, infinite or NaN direction
|
/// the shader both take (see `TextInstance`). A zero, infinite or NaN direction
|
||||||
|
|||||||
@@ -1043,8 +1043,8 @@ void Renderer::draw_traces(const Plot& plot, const PlotLayout& layout) {
|
|||||||
const f64 x_abs = series.x0() + static_cast<f64>(gather_[k]);
|
const f64 x_abs = series.x0() + static_cast<f64>(gather_[k]);
|
||||||
const f64 y_abs = static_cast<f64>(gather_[k + 1]);
|
const f64 y_abs = static_cast<f64>(gather_[k + 1]);
|
||||||
if (!std::isfinite(x_abs) || !std::isfinite(y_abs)) continue;
|
if (!std::isfinite(x_abs) || !std::isfinite(y_abs)) continue;
|
||||||
const f32 sx = xt.to_screen_x(x_abs);
|
const f32 sx = static_cast<f32>(xt.to_screen_x(x_abs));
|
||||||
const f32 sy = yt.to_screen_y(y_abs);
|
const f32 sy = static_cast<f32>(yt.to_screen_y(y_abs));
|
||||||
if (!(sx >= layout.axes.x && sx <= layout.axes.right() && sy >= layout.axes.y &&
|
if (!(sx >= layout.axes.x && sx <= layout.axes.right() && sy >= layout.axes.y &&
|
||||||
sy <= layout.axes.bottom())) {
|
sy <= layout.axes.bottom())) {
|
||||||
continue;
|
continue;
|
||||||
@@ -1085,12 +1085,12 @@ void Renderer::draw_traces(const Plot& plot, const PlotLayout& layout) {
|
|||||||
usize kept = 0;
|
usize kept = 0;
|
||||||
f64 next = std::numeric_limits<f64>::infinity();
|
f64 next = std::numeric_limits<f64>::infinity();
|
||||||
for (usize k = count; k > 0; --k) {
|
for (usize k = count; k > 0; --k) {
|
||||||
const usize i = k - 1u;
|
const usize p = k - 1u; // the point index; `i` above is the trace's
|
||||||
const f64 x = static_cast<f64>(gather_[2u * i]) + series.x0();
|
const f64 x = static_cast<f64>(gather_[2u * p]) + series.x0();
|
||||||
if (!(x < next)) continue; // out of order with what follows: unreadable, and a NaN too
|
if (!(x < next)) continue; // out of order with what follows: unreadable, and a NaN too
|
||||||
next = x;
|
next = x;
|
||||||
gather_[2u * (count - 1u - kept)] = gather_[2u * i];
|
gather_[2u * (count - 1u - kept)] = gather_[2u * p];
|
||||||
gather_[2u * (count - 1u - kept) + 1u] = gather_[2u * i + 1u];
|
gather_[2u * (count - 1u - kept) + 1u] = gather_[2u * p + 1u];
|
||||||
++kept;
|
++kept;
|
||||||
}
|
}
|
||||||
if (kept != count) {
|
if (kept != count) {
|
||||||
|
|||||||
Reference in new issue
Block a user