Skip to content

Commit f1b65d6

Browse files
refactor: limit scope of local variable and declare const
1 parent 1d73654 commit f1b65d6

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

diagnostic_aggregator/src/aggregator.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ void Aggregator::publishData()
228228
diag_toplevel_state.level = -1;
229229
int min_level = 255;
230230
uint non_ok_status_depth = 0;
231-
uint depth = 0;
232231
uint report_idx = 0;
233232

234233
vector<boost::shared_ptr<diagnostic_msgs::DiagnosticStatus> > processed;
@@ -240,7 +239,7 @@ void Aggregator::publishData()
240239
{
241240
diag_array.status.push_back(*processed[i]);
242241

243-
depth = static_cast<uint>(std::count(processed[i]->name.begin(), processed[i]->name.end(), '/'));
242+
const uint depth = static_cast<uint>(std::count(processed[i]->name.begin(), processed[i]->name.end(), '/'));
244243
if (processed[i]->level > diag_toplevel_state.level)
245244
{
246245
diag_toplevel_state.level = processed[i]->level;
@@ -279,7 +278,7 @@ void Aggregator::publishData()
279278
{
280279
diag_array.status.push_back(*processed_other[i]);
281280

282-
depth = static_cast<uint>(std::count(processed[i]->name.begin(), processed[i]->name.end(), '/'));
281+
const uint depth = static_cast<uint>(std::count(processed[i]->name.begin(), processed[i]->name.end(), '/'));
283282
if (processed_other[i]->level > diag_toplevel_state.level)
284283
{
285284
diag_toplevel_state.level = processed_other[i]->level;

0 commit comments

Comments
 (0)