More simplifications and faster yet!

Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2021-10-22 10:51:36 +01:00
parent 6e364ad774
commit e9df345577
5 changed files with 10 additions and 29 deletions

View File

@ -13,6 +13,6 @@ void cycles_t::add(const cycle_t& cycle) {
cycles_t::cycles_t(simdjson::dom::array input) {
assert(m_cycles.empty());
m_cycles.reserve(input.size());
for (const auto& entry : input)
for (auto entry : input)
add(entry);
}

View File

@ -16,8 +16,8 @@ public:
void add(const cycle_t& cycle);
[[nodiscard]] auto begin() const { return m_cycles.begin(); }
[[nodiscard]] auto end() const { return m_cycles.end(); }
[[nodiscard]] auto begin() const noexcept { return m_cycles.begin(); }
[[nodiscard]] auto end() const noexcept { return m_cycles.end(); }
[[nodiscard]] auto size() const noexcept { return m_cycles.size(); }

View File

@ -8,23 +8,9 @@
simdjson::dom::parser opcode_test_suite_t::m_parser;
std::string opcode_test_suite_t::read(std::string path) {
std::ifstream file(path, std::ios::in | std::ios::binary);
const auto size = std::filesystem::file_size(path);
std::string result(size, '\0');
file.read(result.data(), size);
return result;
}
opcode_test_suite_t::opcode_test_suite_t(std::string path)
: m_path(path) {}
void opcode_test_suite_t::load() {
m_contents = read(path());
}
void opcode_test_suite_t::parse() {
m_raw = m_parser.parse(m_contents);
m_contents.clear();
m_contents.shrink_to_fit();
m_raw = m_parser.load(path());
}

View File

@ -11,18 +11,16 @@ private:
// Therefore, it can only be used for one document at a time.
static simdjson::dom::parser m_parser;
[[nodiscard]] static std::string read(std::string path);
std::string m_path;
std::string m_contents;
simdjson::dom::element m_raw;
simdjson::dom::array m_raw;;
public:
opcode_test_suite_t(std::string path);
[[nodiscard]] constexpr const auto& path() const noexcept { return m_path; }
[[nodiscard]] const auto raw() const noexcept { return m_raw; }
void load(); // Reads into contents
void parse(); // Parse the contents
void load();
[[nodiscard]] auto begin() const noexcept { return m_raw.begin(); }
[[nodiscard]] auto end() const noexcept { return m_raw.end(); }
};

View File

@ -25,15 +25,12 @@ int main() {
std::cout << "Processing: " << path.filename() << "\n";
opcode_test_suite_t opcode(path.string());
opcode.load();
opcode.parse();
const auto opcode_test_array = opcode.raw().get_array();
bool opcode_undocumented = false;
bool opcode_unimplemented = false;
bool opcode_invalid = false;
for (const auto& opcode_test_element : opcode_test_array) {
for (auto opcode_test_element : opcode) {
const auto opcode_test = test_t(opcode_test_element);