From 7a1153be65c056efb284d4662d40fcb115d1ffed Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 5 Dec 2024 17:30:30 -0500 Subject: [PATCH] Improve loop detection. --- Analyser/Static/Commodore/StaticAnalyser.cpp | 5 +++-- .../Mac/Clock SignalTests/CommodoreStaticAnalyserTests.mm | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Analyser/Static/Commodore/StaticAnalyser.cpp b/Analyser/Static/Commodore/StaticAnalyser.cpp index cbdb6fe7d..656ec9859 100644 --- a/Analyser/Static/Commodore/StaticAnalyser.cpp +++ b/Analyser/Static/Commodore/StaticAnalyser.cpp @@ -21,6 +21,7 @@ #include #include #include +#include using namespace Analyser::Static::Commodore; @@ -84,7 +85,7 @@ std::optional analyse(const File &file) { // a machine code entry point. BASICAnalysis analysis; - std::set visited_lines; + std::unordered_set visited_lines; while(true) { // Analysis has failed if there isn't at least one complete BASIC line from here. if(size_t(line_address - file.starting_address) + 5 >= file.data.size()) { @@ -123,7 +124,7 @@ std::optional analyse(const File &file) { // Exit if a formal end of the program has been declared or if, as some copy protections do, // the linked list of line contents has been made circular. - visited_lines.insert(line_number); + visited_lines.insert(line_address); if(!next_line_address || visited_lines.find(next_line_address) != visited_lines.end()) { break; } diff --git a/OSBindings/Mac/Clock SignalTests/CommodoreStaticAnalyserTests.mm b/OSBindings/Mac/Clock SignalTests/CommodoreStaticAnalyserTests.mm index f2dc2e2c0..aa58b7514 100644 --- a/OSBindings/Mac/Clock SignalTests/CommodoreStaticAnalyserTests.mm +++ b/OSBindings/Mac/Clock SignalTests/CommodoreStaticAnalyserTests.mm @@ -46,6 +46,7 @@ struct HitRate { continue; } + NSLog(@"%@", diskItem); const auto list = Analyser::Static::GetTargets([path stringByAppendingPathComponent:diskItem].UTF8String); if(list.empty()) { continue; @@ -58,6 +59,11 @@ struct HitRate { const auto &first = *list.begin(); hits.matches += first->machine == machine; + +// if(!(hits.files % 100)) { + NSLog(@"Currently %d in %d, i.e. %0.2f", + hits.matches, hits.files, float(hits.matches) / float(hits.files)); +// } } return hits;