Skip to content

Commit 7bf391c

Browse files
authored
fix potential use of uninitialized value warning, avoid casting away const
This fixes a "potentially use of uninitialized value" warning, as well as a cstyle cast to non-const.
1 parent 07a6e09 commit 7bf391c

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

benchmark/largerandom/sax.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,14 @@ class Sax {
2626
std::vector<my_point> container{};
2727
};
2828

29-
using namespace simdjson;
30-
using namespace simdjson::builtin;
31-
using namespace simdjson::builtin::stage2;
3229
struct sax_point_reader_visitor {
3330
public:
3431
std::vector<my_point> &points;
3532
enum {GOT_X=0, GOT_Y=1, GOT_Z=2, GOT_SOMETHING_ELSE=4};
3633
size_t idx{GOT_SOMETHING_ELSE};
37-
double buffer[3];
34+
double buffer[3]={};
3835

39-
sax_point_reader_visitor(std::vector<my_point> &_points) : points(_points) {}
36+
explicit sax_point_reader_visitor(std::vector<my_point> &_points) : points(_points) {}
4037

4138
simdjson_really_inline error_code visit_object_start(json_iterator &) {
4239
idx = 0;
@@ -96,7 +93,7 @@ error_code Sax::RunNoExcept(const padded_string &json) noexcept {
9693
}
9794

9895
// Run stage 1 first.
99-
SIMDJSON_TRY( dom_parser.stage1((uint8_t *)json.data(), json.size(), false) );
96+
SIMDJSON_TRY( dom_parser.stage1(json.u8data(), json.size(), false) );
10097

10198
// Then walk the document, parsing the tweets as we go
10299
json_iterator iter(dom_parser, 0);

include/simdjson/padded_string.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ struct padded_string final {
8585
* The string data.
8686
**/
8787
const char *data() const noexcept;
88+
const uint8_t *u8data() const noexcept { return static_cast<const uint8_t*>(static_cast<const void*>(data_ptr));}
8889

8990
/**
9091
* The string data.

0 commit comments

Comments
 (0)