Skip to content

Commit

Permalink
[precommit] - Apply clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Almagro committed Apr 29, 2024
1 parent ae9850e commit d620d62
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:

# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -38,7 +38,7 @@ repos:

# CPP hooks
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
rev: v18.1.4
hooks:
- id: clang-format
args: ['-fallback-style=none', '-i']
10 changes: 6 additions & 4 deletions plotjuggler_base/include/PlotJuggler/reactive_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ class CreatedSeriesXY;

namespace PJ
{
enum class MatchType {
Exact, // Returns an index only if the exact time is found
Nearest // Returns the nearest time index (current behavior)
enum class MatchType
{
Exact, // Returns an index only if the exact time is found
Nearest // Returns the nearest time index (current behavior)
};

struct TimeseriesRef
Expand All @@ -32,7 +33,8 @@ struct TimeseriesRef

double atTime(double t, MatchType match_type) const;

std::optional<unsigned> getRawIndexAtTime(double t, MatchType match_type) const; // Method signature updated
std::optional<unsigned>
getRawIndexAtTime(double t, MatchType match_type) const; // Method signature updated

unsigned size() const;

Expand Down
13 changes: 6 additions & 7 deletions plotjuggler_base/src/reactive_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,23 +195,22 @@ double TimeseriesRef::atTime(double t, MatchType match_type) const
return _plot_data->at(*index).y;
}

std::optional<unsigned> TimeseriesRef::getRawIndexAtTime(double t, MatchType match_type) const
std::optional<unsigned> TimeseriesRef::getRawIndexAtTime(double t,
MatchType match_type) const
{
if (match_type == MatchType::Exact)
{
auto it = std::find_if(
_plot_data->begin(),
_plot_data->end(),
[t](const auto& point) { return point.x == t; });
auto it = std::find_if(_plot_data->begin(), _plot_data->end(),
[t](const auto& point) { return point.x == t; });

Check notice

Code scanning / CodeQL

Equality test on floating-point values Note

Equality checks on floating point values can yield unexpected results.
if (it != _plot_data->end())
{
return std::distance(_plot_data->begin(), it);
}
return std::nullopt; // Exact time not found
return std::nullopt; // Exact time not found
}
else
{
return _plot_data->getIndexFromX(t); // Nearest match
return _plot_data->getIndexFromX(t); // Nearest match
}
}

Expand Down

0 comments on commit d620d62

Please sign in to comment.