Switched to reading the entire file into a buffer at the start.\nThis speeds it up a TON (like 100x).

This commit is contained in:
Jesse Beder
2009-02-01 20:48:43 +00:00
parent a6d5902ebf
commit f9c0725684
9 changed files with 72 additions and 75 deletions

View File

@@ -7,20 +7,13 @@
void run()
{
std::ifstream fin("tests/test.yaml");
YAML::Parser parser(fin);
try {
YAML::Parser parser(fin);
while(parser)
{
YAML::Node doc;
parser.GetNextDocument(doc);
std::cout << "name: " << doc["name"] << "\n";
std::cout << "age: " << doc["age"] << "\n";
} catch(YAML::TypedKeyNotFound <std::string>& e) {
std::cout << "Key '" << e.key << "' not found at line " << e.line+1 << ", col " << e.column+1 << "\n";
} catch(YAML::KeyNotFound& e) {
std::cout << "Key not found at line " << e.line+1 << ", col " << e.column+1 << "\n";
} catch(YAML::Exception& e) {
std::cout << "Error at line " << e.line+1 << ", col " << e.column+1 << ": " << e.msg << "\n";
std::cout << doc;
}
}