Skip to content

Commit 25b09d9

Browse files
committedNov 20, 2024
Fix error message when #TypeAxisNames != #TypeAxes.
The error message was being generated after moving strings out of `names`, so some of the axis names were blank. This moves the check + error before any strings are moved.
1 parent f52aa4b commit 25b09d9

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed
 

‎nvbench/axes_metadata.cxx

+8-11
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
*/
1818

1919
#include <nvbench/axes_metadata.cuh>
20-
2120
#include <nvbench/detail/throw.cuh>
2221

23-
#include <fmt/format.h>
24-
#include <fmt/ranges.h>
25-
2622
#include <algorithm>
23+
#include <cassert>
2724
#include <stdexcept>
2825

26+
#include <fmt/format.h>
27+
#include <fmt/ranges.h>
28+
2929
namespace nvbench
3030
{
3131

@@ -52,21 +52,18 @@ axes_metadata &axes_metadata::operator=(const axes_metadata &other)
5252
void axes_metadata::set_type_axes_names(std::vector<std::string> names)
5353
try
5454
{
55-
if (names.size() < m_axes.size())
55+
if (names.size() != m_axes.size())
5656
{
5757
NVBENCH_THROW(std::runtime_error,
58-
"Number of names exceeds number of axes ({}).",
58+
"Number of type axis names ({}) exceeds number of type axes ({}).",
59+
names.size(),
5960
m_axes.size());
6061
}
6162

6263
for (std::size_t i = 0; i < names.size(); ++i)
6364
{
6465
auto &axis = *m_axes[i];
65-
if (axis.get_type() != nvbench::axis_type::type)
66-
{
67-
NVBENCH_THROW(std::runtime_error, "Number of names exceeds number of type axes ({})", i);
68-
}
69-
66+
assert(axis.get_type() != nvbench::axis_type::type);
7067
axis.set_name(std::move(names[i]));
7168
}
7269
}

0 commit comments

Comments
 (0)
Failed to load comments.