diff --git a/M6502/HarteTest_6502/cycles_t.cpp b/M6502/HarteTest_6502/cycles_t.cpp index 24e2091..e1832e5 100644 --- a/M6502/HarteTest_6502/cycles_t.cpp +++ b/M6502/HarteTest_6502/cycles_t.cpp @@ -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); } diff --git a/M6502/HarteTest_6502/cycles_t.h b/M6502/HarteTest_6502/cycles_t.h index 267fa24..264b7a2 100644 --- a/M6502/HarteTest_6502/cycles_t.h +++ b/M6502/HarteTest_6502/cycles_t.h @@ -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(); } diff --git a/M6502/HarteTest_6502/opcode_test_suite_t.cpp b/M6502/HarteTest_6502/opcode_test_suite_t.cpp index 51c5873..01f8111 100644 --- a/M6502/HarteTest_6502/opcode_test_suite_t.cpp +++ b/M6502/HarteTest_6502/opcode_test_suite_t.cpp @@ -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()); } diff --git a/M6502/HarteTest_6502/opcode_test_suite_t.h b/M6502/HarteTest_6502/opcode_test_suite_t.h index 5fa7d63..6a20abb 100644 --- a/M6502/HarteTest_6502/opcode_test_suite_t.h +++ b/M6502/HarteTest_6502/opcode_test_suite_t.h @@ -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(); } }; diff --git a/M6502/HarteTest_6502/tests.cpp b/M6502/HarteTest_6502/tests.cpp index d95352c..eea3440 100644 --- a/M6502/HarteTest_6502/tests.cpp +++ b/M6502/HarteTest_6502/tests.cpp @@ -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);