diff options
| author | Miodrag Milanović <mmicko@gmail.com> | 2020-05-21 15:36:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-21 15:36:30 +0200 |
| commit | 637650597b27a2e2f5407fc128ffd21d7a0b3016 (patch) | |
| tree | f6c29b8d0e4f3a16ef8db59abfc8b94585a1fc5e /passes | |
| parent | 026fed31356faa5a1b21a6270dd5cf0c745bb76e (diff) | |
| parent | 8297afe92588c881fbf0590a64c81af08e6f20f6 (diff) | |
| download | yosys-637650597b27a2e2f5407fc128ffd21d7a0b3016.tar.gz yosys-637650597b27a2e2f5407fc128ffd21d7a0b3016.tar.bz2 yosys-637650597b27a2e2f5407fc128ffd21d7a0b3016.zip | |
Merge pull request #2059 from boqwxp/logger-vector-to-dict
log: Use `dict` instead of `std::vector<std::pair>` for `log_expect_{error, warning, log}` to better express the intent that each element is unique.
Diffstat (limited to 'passes')
| -rw-r--r-- | passes/cmds/logger.cc | 39 |
1 files changed, 6 insertions, 33 deletions
diff --git a/passes/cmds/logger.cc b/passes/cmds/logger.cc index 50b89d92f..c9532eced 100644 --- a/passes/cmds/logger.cc +++ b/passes/cmds/logger.cc @@ -159,39 +159,12 @@ struct LoggerPass : public Pass { log_cmd_error("Expected error message occurrences must be 1 !\n"); log("Added regex '%s' for warnings to expected %s list.\n", pattern.c_str(), type.c_str()); try { - if (type=="error") { - auto it = log_expect_error.begin(); - auto ie = log_expect_error.end(); - for (; it != ie; it++) - if (it->second.pattern == pattern) { - it->second.expected_count = count; - break; - } - if (it == ie) - log_expect_error.emplace_back(YS_REGEX_COMPILE(pattern), LogExpectedItem(pattern, count)); - } - else if (type=="warning") { - auto it = log_expect_warning.begin(); - auto ie = log_expect_warning.end(); - for (; it != ie; it++) - if (it->second.pattern == pattern) { - it->second.expected_count = count; - break; - } - if (it == ie) - log_expect_warning.emplace_back(YS_REGEX_COMPILE(pattern), LogExpectedItem(pattern, count)); - } - else if (type=="log") { - auto it = log_expect_log.begin(); - auto ie = log_expect_log.end(); - for (; it != ie; it++) - if (it->second.pattern == pattern) { - it->second.expected_count = count; - break; - } - if (it == ie) - log_expect_log.emplace_back(YS_REGEX_COMPILE(pattern), LogExpectedItem(pattern, count)); - } + if (type == "error") + log_expect_error[pattern] = LogExpectedItem(YS_REGEX_COMPILE(pattern), count); + else if (type == "warning") + log_expect_warning[pattern] = LogExpectedItem(YS_REGEX_COMPILE(pattern), count); + else if (type == "log") + log_expect_log[pattern] = LogExpectedItem(YS_REGEX_COMPILE(pattern), count); else log_abort(); } catch (const YS_REGEX_NS::regex_error& e) { |
