From 00d303eeadf23f394836ecd317eb800f0047a0bf Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 8 Jan 2013 14:41:58 -0600 Subject: [PATCH] clean up FifoPlayerDlg::OnBeginSearch a bit --- Source/Core/DolphinWX/Src/FifoPlayerDlg.cpp | 27 ++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/Source/Core/DolphinWX/Src/FifoPlayerDlg.cpp b/Source/Core/DolphinWX/Src/FifoPlayerDlg.cpp index 494931f959..160aaf211a 100644 --- a/Source/Core/DolphinWX/Src/FifoPlayerDlg.cpp +++ b/Source/Core/DolphinWX/Src/FifoPlayerDlg.cpp @@ -22,9 +22,13 @@ #include "FifoPlayer/FifoPlayer.h" #include "FifoPlayer/FifoRecorder.h" #include "OpcodeDecoding.h" + #include #include +#include +#include + DECLARE_EVENT_TYPE(RECORDING_FINISHED_EVENT, -1) DEFINE_EVENT_TYPE(RECORDING_FINISHED_EVENT) @@ -440,26 +444,22 @@ void FifoPlayerDlg::OnBeginSearch(wxCommandEvent& event) return; } - unsigned int val_length = str_search_val.Length() / 2; - u8* search_val = new u8[val_length]; + unsigned int const val_length = str_search_val.Length() / 2; + std::vector search_val(val_length); for (unsigned int i = 0; i < val_length; ++i) { wxString char_str = str_search_val.Mid(2*i, 2); - unsigned long val; + unsigned long val = 0; if (!char_str.ToULong(&val, 16)) { m_numResultsText->SetLabel(_("Invalid search string (couldn't convert to number)")); - delete[] search_val; return; } search_val[i] = (u8)val; } search_results.clear(); - u8* start_ptr; - u8* end_ptr; - - int frame_idx = m_framesList->GetSelection(); + int const frame_idx = m_framesList->GetSelection(); FifoPlayer& player = FifoPlayer::GetInstance(); const AnalyzedFrameInfo& frame = player.GetAnalyzedFrameInfo(frame_idx); const FifoFrameInfo& fifo_frame = player.GetFile()->GetFrame(frame_idx); @@ -470,15 +470,15 @@ void FifoPlayerDlg::OnBeginSearch(wxCommandEvent& event) if (obj_idx == -1) { m_numResultsText->SetLabel(_("Invalid search parameters (no object selected)")); - delete[] search_val; return; } - start_ptr = &fifo_frame.fifoData[frame.objectStarts[obj_idx]]; - end_ptr = &fifo_frame.fifoData[frame.objectStarts[obj_idx+1]]; - for (u8* ptr = start_ptr; ptr < end_ptr-val_length+1; ++ptr) + const u8* const start_ptr = &fifo_frame.fifoData[frame.objectStarts[obj_idx]]; + const u8* const end_ptr = &fifo_frame.fifoData[frame.objectStarts[obj_idx+1]]; + + for (const u8* ptr = start_ptr; ptr < end_ptr-val_length+1; ++ptr) { - if (memcmp(ptr, search_val, val_length) == 0) + if (std::equal(search_val.begin(), search_val.end(), ptr)) { SearchResult result; result.frame_idx = frame_idx; @@ -497,7 +497,6 @@ void FifoPlayerDlg::OnBeginSearch(wxCommandEvent& event) search_results.push_back(result); } } - delete[] search_val; ChangeSearchResult(0); m_beginSearch->Disable();