YAML loading optimization (#5997)

* Use rapidyaml library to parse YAML databases instead of yaml-cpp.
* Drastically reduces the parse time for yaml databases.
* Removes yaml-cpp content from main servers, except for tool emitter.
Co-authored-by: Vincent Stumpf <vincents.995@gmail.com>
Co-authored-by: Atemo <capucrath@gmail.com>
Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
This commit is contained in:
Jittapan Pluemsumran
2022-03-31 03:38:52 +07:00
committed by GitHub
parent 9bc1c53db4
commit d1b7061f5a
303 changed files with 60500 additions and 916 deletions

View File

@@ -17,6 +17,8 @@
#endif
#include <yaml-cpp/yaml.h>
#include <ryml_std.hpp>
#include <ryml.hpp>
#include "../common/cbasetypes.hpp"
#include "../common/core.hpp"
@@ -77,7 +79,7 @@ bool fileExists( const std::string& path );
bool askConfirmation( const char* fmt, ... );
YAML::Node inNode;
std::ofstream out;
std::ofstream outFile;
// Implement the function instead of including the original version by linking
void script_set_constant_(const char *name, int64 value, const char *constant_name, bool isparameter, bool deprecated) {
@@ -167,21 +169,21 @@ bool process( const std::string& type, uint32 version, const std::vector<std::st
}
#endif
out.open(to);
outFile.open(to);
if (!out.is_open()) {
if (!outFile.is_open()) {
ShowError("Can not open file \"%s\" for writing.\n", to.c_str());
return false;
}
prepareHeader(out, table.compare(to_table) == 0 ? table : to_table);
prepareHeader(outFile, table.compare(to_table) == 0 ? table : to_table);
if( !lambda( path, name_ext, table ) ){
out.close();
outFile.close();
return false;
}
out.close();
outFile.close();
}
}
@@ -712,11 +714,11 @@ static bool item_db_yaml2sql(const std::string &file, const std::string &table)
column.pop_back(); // Remove last ','
value.pop_back(); // Remove last ','
out << "REPLACE INTO `" + table + "` (" + column + ") VALUES (" + value + ");\n";
outFile << "REPLACE INTO `" + table + "` (" + column + ") VALUES (" + value + ");\n";
entries++;
}
ShowStatus("Done converting '" CL_WHITE "%d" CL_RESET "' items in '" CL_WHITE "%s" CL_RESET "'.\n", entries, file.c_str());
ShowStatus("Done converting '" CL_WHITE "%zu" CL_RESET "' items in '" CL_WHITE "%s" CL_RESET "'.\n", entries, file.c_str());
return true;
}
@@ -917,11 +919,11 @@ static bool mob_db_yaml2sql(const std::string &file, const std::string &table) {
column.pop_back(); // Remove last ','
value.pop_back(); // Remove last ','
out << "REPLACE INTO `" + table + "` (" + column + ") VALUES (" + value + ");\n";
outFile << "REPLACE INTO `" + table + "` (" + column + ") VALUES (" + value + ");\n";
entries++;
}
ShowStatus("Done converting '" CL_WHITE "%d" CL_RESET "' mobs in '" CL_WHITE "%s" CL_RESET "'.\n", entries, file.c_str());
ShowStatus("Done converting '" CL_WHITE "%zu" CL_RESET "' mobs in '" CL_WHITE "%s" CL_RESET "'.\n", entries, file.c_str());
return true;
}