Integrating the new 3-stage approach.
This commit is contained in:
parent
cb26dc9c7b
commit
dee1bbe54e
|
@ -46,6 +46,7 @@ int main(int argc, char *argv[]) {
|
|||
int repeat = 10;
|
||||
int volume = p.second;
|
||||
BEST_TIME(json_parse(p.first, p.second, pj), true, , repeat, volume, true);
|
||||
BEST_TIME(json_parse_4stages(p.first, p.second, pj), true, , repeat, volume, true);
|
||||
|
||||
rapidjson::Document d;
|
||||
|
||||
|
|
|
@ -21,3 +21,6 @@ void deallocate_ParsedJson(ParsedJson *pj_ptr);
|
|||
// Parse a document found in buf, need to preallocate ParsedJson.
|
||||
// Return false in case of a failure.
|
||||
bool json_parse(const u8 *buf, size_t len, ParsedJson &pj);
|
||||
|
||||
// like json_parse but users 4 stages, slower.
|
||||
bool json_parse_4stages(const u8 *buf, size_t len, ParsedJson &pj);
|
|
@ -44,8 +44,9 @@ void deallocate_ParsedJson(ParsedJson *pj_ptr) {
|
|||
delete pj_ptr;
|
||||
}
|
||||
|
||||
// parse a document found in buf, need to preallocate ParsedJson.
|
||||
bool json_parse(const u8 *buf, size_t len, ParsedJson &pj) {
|
||||
// parse a document found in buf, need to preallocate ParsedJson.
|
||||
// this can probably be considered a legacy function at this point.
|
||||
bool json_parse_4stages(const u8 *buf, size_t len, ParsedJson &pj) {
|
||||
if (pj.bytecapacity < len) {
|
||||
std::cerr << "Your ParsedJson cannot support documents that big: " << len
|
||||
<< std::endl;
|
||||
|
@ -63,3 +64,21 @@ bool json_parse(const u8 *buf, size_t len, ParsedJson &pj) {
|
|||
}
|
||||
return isok;
|
||||
}
|
||||
|
||||
// parse a document found in buf, need to preallocate ParsedJson.
|
||||
bool json_parse(const u8 *buf, size_t len, ParsedJson &pj) {
|
||||
if (pj.bytecapacity < len) {
|
||||
std::cerr << "Your ParsedJson cannot support documents that big: " << len
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
bool isok = find_structural_bits(buf, len, pj);
|
||||
if (isok) {
|
||||
isok = flatten_indexes(len, pj);
|
||||
}
|
||||
if (isok) {
|
||||
isok = unified_machine(buf, len, pj);
|
||||
}
|
||||
return isok;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue