Simplify std::find_if with Common::Contains

This commit is contained in:
mitaclaw 2024-09-21 14:50:23 -07:00
parent 110d32729e
commit d92c68e1de
5 changed files with 25 additions and 49 deletions

View file

@ -16,6 +16,7 @@
#include <QToolBar>
#include <QVBoxLayout>
#include "Common/Contains.h"
#include "Common/FileUtil.h"
#include "Common/IniFile.h"
#include "Core/ConfigManager.h"
@ -522,10 +523,7 @@ void BreakpointWidget::OnContextMenu(const QPoint& pos)
if (!is_memory_breakpoint)
{
const auto& inst_breakpoints = m_system.GetPowerPC().GetBreakPoints().GetBreakPoints();
const auto bp_iter =
std::find_if(inst_breakpoints.begin(), inst_breakpoints.end(),
[bp_address](const auto& bp) { return bp.address == bp_address; });
if (bp_iter == inst_breakpoints.end())
if (!Common::Contains(inst_breakpoints, bp_address, &TBreakPoint::address))
return;
menu->addAction(tr("Show in Code"), [this, bp_address] { emit ShowCode(bp_address); });
@ -538,10 +536,7 @@ void BreakpointWidget::OnContextMenu(const QPoint& pos)
else
{
const auto& memory_breakpoints = m_system.GetPowerPC().GetMemChecks().GetMemChecks();
const auto mb_iter =
std::find_if(memory_breakpoints.begin(), memory_breakpoints.end(),
[bp_address](const auto& bp) { return bp.start_address == bp_address; });
if (mb_iter == memory_breakpoints.end())
if (!Common::Contains(memory_breakpoints, bp_address, &TMemCheck::start_address))
return;
menu->addAction(tr("Show in Memory"), [this, bp_address] { emit ShowMemory(bp_address); });