From 10c9362b4f7f38d8986f3920d3847d56bb1b458c Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 27 May 2024 13:51:37 +0200 Subject: [PATCH] mapping: disambiguate local variable el Reported-by: Xcode Signed-off-by: Simon Rozman --- include/stdex/mapping.hpp | 52 +++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/include/stdex/mapping.hpp b/include/stdex/mapping.hpp index 0c6cb18b7..2d94349ae 100644 --- a/include/stdex/mapping.hpp +++ b/include/stdex/mapping.hpp @@ -132,19 +132,21 @@ namespace stdex return to; size_t l, r; - const auto& el = mapping[m]; - if (to < el.to) { - l = 0; - r = m; + { + const auto& el = mapping[m]; + if (to < el.to) { + l = 0; + r = m; + } + else if (el.to < to) { + if (mapping.size() - 1 <= m || to < mapping[m + 1].to) + return el.from + (to - el.to); + l = m + 1; + r = mapping.size(); + } + else + return el.from; } - else if (el.to < to) { - if (mapping.size() - 1 <= m || to < mapping[m + 1].to) - return el.from + (to - el.to); - l = m + 1; - r = mapping.size(); - } - else - return el.from; for (;;) { if (l < r) { @@ -214,19 +216,21 @@ namespace stdex return from; size_t l, r; - const auto& el = mapping[m]; - if (from < el.from) { - l = 0; - r = m; + { + const auto& el = mapping[m]; + if (from < el.from) { + l = 0; + r = m; + } + else if (el.from < from) { + if (mapping.size() - 1 <= m || from < mapping[m + 1].from) + return el.to + (from - el.from); + l = m + 1; + r = mapping.size(); + } + else + return el.to; } - else if (el.from < from) { - if (mapping.size() - 1 <= m || from < mapping[m + 1].from) - return el.to + (from - el.from); - l = m + 1; - r = mapping.size(); - } - else - return el.to; for (;;) { if (l < r) {