Skip to content

Commit deeb9cf

Browse files
committed
avoid duplicate program updates
1 parent c97f91f commit deeb9cf

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ To install or update LODA, please follow the [installation instructions](https:/
22

33
## [Unreleased]
44

5+
# v22.9.12
6+
7+
### Bugfixes
8+
9+
* Additional check to avoid duplicate program updates
10+
511
### Enhancements
612

713
* Internal `compare` command for checking if a program is faster/better

src/oeis_manager.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,6 @@ update_program_result_t OeisManager::updateProgram(
695695
optimizer.removeNops(existing);
696696
optimizer.removeNops(p);
697697
if (p == existing) {
698-
// Log::get().info("Skipping update for " + seq.id_str() + "
699-
// (unchanged)");
700698
return result;
701699
}
702700
}
@@ -717,25 +715,24 @@ update_program_result_t OeisManager::updateProgram(
717715
num_default_terms);
718716
break;
719717
}
720-
if (checked.first.empty()) {
718+
// not better or the same after optimization?
719+
if (checked.first.empty() || (!is_new && checked.second == existing)) {
721720
return result;
722721
}
723722

724723
// update result
725724
result.updated = true;
726725
result.is_new = is_new;
726+
result.program = checked.second;
727727
result.change_type = checked.first;
728728
if (!is_new) {
729729
result.previous_hash = ProgramUtil::hash(existing, true);
730730
}
731731

732732
// write new or better program version
733-
result.program = checked.second;
734-
if (Setup::getMiningMode() == MINING_MODE_SERVER) {
735-
dumpProgram(id, result.program, global_file, submitted_by);
736-
} else {
737-
dumpProgram(id, result.program, local_file, submitted_by);
738-
}
733+
const bool is_server = (Setup::getMiningMode() == MINING_MODE_SERVER);
734+
const std::string target_file = is_server ? global_file : local_file;
735+
dumpProgram(id, result.program, target_file, submitted_by);
739736

740737
// if not updating, ignore this sequence for future matches;
741738
// this is important for performance: it is likly that we

0 commit comments

Comments
 (0)