+ overworked parser
This commit is contained in:
parent
4e44390090
commit
9e61092fc6
3 changed files with 19 additions and 3 deletions
|
@ -7,7 +7,7 @@ json_unit_CXXFLAGS = $(FLAGS) -std=c++11
|
|||
json_unit_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/test -Dprivate=public
|
||||
|
||||
json_parser_SOURCES = src/JSON.cc src/JSON.h benchmark/parse.cc
|
||||
json_parser_CXXFLAGS = $(FLAGS) -std=c++11
|
||||
json_parser_CXXFLAGS = -O3 -std=c++11 -flto
|
||||
json_parser_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/benchmark
|
||||
|
||||
cppcheck:
|
||||
|
@ -24,3 +24,6 @@ pretty:
|
|||
--align-reference=type --add-brackets --convert-tabs --close-templates \
|
||||
--lineend=linux --preserve-date --suffix=none \
|
||||
$(SOURCES)
|
||||
|
||||
parser:
|
||||
make CXXFLAGS="" json_parser
|
6
json_parser.py
Executable file
6
json_parser.py
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import json
|
||||
|
||||
j = json.load(sys.stdin)
|
11
src/JSON.cc
11
src/JSON.cc
|
@ -1776,8 +1776,15 @@ Initialize the JSON parser given an input stream \p _is.
|
|||
JSON::Parser::Parser(std::istream& _is)
|
||||
{
|
||||
// copy stream to string
|
||||
std::istreambuf_iterator<char> eos;
|
||||
std::string string_input(std::istreambuf_iterator<char>(_is), eos);
|
||||
std::string input_line, string_input;
|
||||
|
||||
// from http://www.manticmoo.com/articles/jeff/programming/c++/making-io-streams-efficient-in-c++.php
|
||||
// Don't sync C++ and C I/O
|
||||
std::ios_base::sync_with_stdio(false);
|
||||
while(_is) {
|
||||
std::getline(_is, input_line);
|
||||
string_input += input_line;
|
||||
}
|
||||
|
||||
_length = string_input.size();
|
||||
_buffer = new char[_length + 1];
|
||||
|
|
Loading…
Reference in a new issue