Skip to content

Commit 57e8bae

Browse files
committed
Remove this use of the constructor's initializer list for data member. It is redundant with the in-class initializer.
Use "std::array" or "std::vector" instead of a C-style array.
1 parent 0178fee commit 57e8bae

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

include/Structure_Helper.h

+5-8
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,14 @@ struct PolarPoint
280280
* @param _distance
281281
* @param _confidence
282282
*/
283-
PolarPoint(float _angle, int16_t _distance, uint16_t _confidence) : angle(_angle), distance(_distance), confidence(_confidence), x(0), y(0) {}
283+
PolarPoint(float _angle, int16_t _distance, uint16_t _confidence) : angle(_angle), distance(_distance), confidence(_confidence){}
284284
/**
285285
* @brief Construct a new Polar Point object
286286
*
287287
* @param _x
288288
* @param _y
289289
*/
290-
PolarPoint(float _x, float _y) : angle(0), distance(0), confidence(0), x(_x), y(_y) {}
290+
PolarPoint(float _x, float _y) : x(_x), y(_y) {}
291291
/**
292292
* @brief Construct a new Polar Point object
293293
* @param _angle
@@ -319,17 +319,14 @@ struct Command
319319
static const int8_t sizeStr = 14;
320320
String cmd = "";
321321
int8_t size;
322-
int32_t data[length];
323-
String dataStr; //sizeof(String) = 16 BUT 1 is for length and 1 for end char so 14 in reality
322+
std::array<int32_t, length> data;
323+
String dataStr; //sizeof(String) = 16 BUT 1 is for string length and 1 for \0 so 14 in reality
324324

325325
Command()
326326
{
327327
cmd = "";
328328
size = 0;
329-
for (size_t i = 0; i < length; i++)
330-
{
331-
data[i] = 0;
332-
}
329+
data.fill(0);
333330
dataStr = "";
334331
}
335332
};

0 commit comments

Comments
 (0)