Making the code cleaner.
This commit is contained in:
parent
157604b3a5
commit
874349c928
|
@ -33,7 +33,8 @@ using namespace SIMDJSON_IMPLEMENTATION::stage2;
|
||||||
struct sax_point_reader_visitor {
|
struct sax_point_reader_visitor {
|
||||||
public:
|
public:
|
||||||
std::vector<my_point> &points;
|
std::vector<my_point> &points;
|
||||||
size_t idx{4};
|
enum {GOT_X=0, GOT_Y=1, GOT_Z=2, GOT_SOMETHING_ELSE=4};
|
||||||
|
size_t idx{GOT_SOMETHING_ELSE};
|
||||||
double buffer[3];
|
double buffer[3];
|
||||||
|
|
||||||
sax_point_reader_visitor(std::vector<my_point> &_points) : points(_points) {}
|
sax_point_reader_visitor(std::vector<my_point> &_points) : points(_points) {}
|
||||||
|
@ -43,7 +44,7 @@ public:
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
simdjson_really_inline error_code visit_primitive(json_iterator &, const uint8_t *value) {
|
simdjson_really_inline error_code visit_primitive(json_iterator &, const uint8_t *value) {
|
||||||
if(idx == 4) { return simdjson::SUCCESS; }
|
if(idx == GOT_SOMETHING_ELSE) { return simdjson::SUCCESS; }
|
||||||
return numberparsing::parse_double(value).get(buffer[idx]);
|
return numberparsing::parse_double(value).get(buffer[idx]);
|
||||||
}
|
}
|
||||||
simdjson_really_inline error_code visit_object_end(json_iterator &) {
|
simdjson_really_inline error_code visit_object_end(json_iterator &) {
|
||||||
|
@ -54,17 +55,20 @@ public:
|
||||||
simdjson_really_inline error_code visit_document_start(json_iterator &) { return SUCCESS; }
|
simdjson_really_inline error_code visit_document_start(json_iterator &) { return SUCCESS; }
|
||||||
simdjson_really_inline error_code visit_key(json_iterator &, const uint8_t * key) {
|
simdjson_really_inline error_code visit_key(json_iterator &, const uint8_t * key) {
|
||||||
switch(key[1]) {
|
switch(key[1]) {
|
||||||
|
// Technically, we should check the other characters
|
||||||
|
// in the key, but we are cheating to go as fast
|
||||||
|
// as possible.
|
||||||
case 'x':
|
case 'x':
|
||||||
idx = 0;
|
idx = GOT_X;
|
||||||
break;
|
break;
|
||||||
case 'y':
|
case 'y':
|
||||||
idx = 1;
|
idx = GOT_Y;
|
||||||
break;
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
idx = 2;
|
idx = GOT_Z;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
idx = 4;
|
idx = GOT_SOMETHING_ELSE;
|
||||||
}
|
}
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue