mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
d036fdf919
Including <iostream> has two problems: * Compile times are worse because of over-inclusion * Binary sizes are worse when statically linking libstdc++ because iostreams cannot be dead-code-stripped simdjson only needs std::ostream. Include the header declaring only what we need (<ostream>), omitting stuff we don't need (std::cout and its initialization, for example). This commit should not change behavior, but it might break users who assume that including <simdjson/simdjson.h> will make std::cout available (such as many of simdjson's own files).
18 lines
481 B
C++
18 lines
481 B
C++
#include <iostream>
|
|
#include "simdjson.h"
|
|
|
|
int main(void) {
|
|
simdjson::dom::parser parser;
|
|
simdjson::dom::element tweets;
|
|
auto error = parser.load("twitter.json").get(tweets);
|
|
if (error) { std::cerr << error << std::endl; return EXIT_FAILURE; }
|
|
simdjson::dom::element res;
|
|
|
|
if ((error = tweets["search_metadata"]["count"].get(res))) {
|
|
std::cerr << "could not access keys" << std::endl;
|
|
return EXIT_FAILURE;
|
|
}
|
|
std::cout << res << " results." << std::endl;
|
|
}
|
|
|