From fa63c9daac6fc74bfc3460be3d8dbd822912e756 Mon Sep 17 00:00:00 2001 From: tqcq Date: Sat, 26 Oct 2024 13:04:02 +0000 Subject: [PATCH] fast --- drama/src/rev-mc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drama/src/rev-mc.c b/drama/src/rev-mc.c index 0823a3f..ed00035 100644 --- a/drama/src/rev-mc.c +++ b/drama/src/rev-mc.c @@ -362,19 +362,24 @@ find_row_mask(std::vector &sets, } diff -= std::min(inner_step, diff); - std::lock_guard _(lock); if (end_pos - diff > g_base_pos) { + std::lock_guard _(lock); if (found) { break; } - g_base_pos = end_pos - diff; - row_mask = cur_mask; + if (end_pos - diff > g_base_pos) { + g_base_pos = end_pos - diff; + row_mask = cur_mask; + } } else if (end_pos >= g_base_pos) { - diff = end_pos - g_base_pos; - cur_mask = row_mask; + std::lock_guard _(lock); + if (end_pos >= g_base_pos) { + diff = end_pos - g_base_pos; + cur_mask = row_mask; + } } } for (int i = outer_step; i > 0 && cur_mask < last_mask; --i) { - if (resolve(cur_mask)) { + if (resolve(cur_mask) && !found) { bool expected = false; if (found.compare_exchange_strong(expected, true)) { std::lock_guard _(lock);