Skip to content

Commit

Permalink
Additional asserts added to the Search.
Browse files Browse the repository at this point in the history
  • Loading branch information
jovibor committed Apr 22, 2024
1 parent 94f126a commit e5df4f2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions HexCtrl/src/Dialogs/CHexDlgSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1916,6 +1916,7 @@ auto CHexDlgSearch::SearchFuncFwd(const SEARCHFUNCDATA& refSearch)->FINDRESULT
for (auto itChunk = 0ULL; itChunk < ullMemChunks; ++itChunk) {
const auto spnData = pHexCtrl->GetData({ ullOffsetSearch, ullMemToAcquire });
assert(!spnData.empty());
assert(spnData.size() >= ullMemToAcquire);

//Unrolling the loop, making LOOP_UNROLL_SIZE comparisons at one cycle.
for (auto ullOffsetData = 0ULL; ullOffsetData <= ullChunkMaxOffset; ullOffsetData += ullStep * LOOP_UNROLL_SIZE) {
Expand Down Expand Up @@ -2025,6 +2026,7 @@ auto CHexDlgSearch::SearchFuncFwdByte1(const SEARCHFUNCDATA& refSearch)->FINDRES
for (auto itChunk = 0ULL; itChunk < ullMemChunks; ++itChunk) {
const auto spnData = pHexCtrl->GetData({ ullOffsetSearch, ullMemToAcquire });
assert(!spnData.empty());
assert(spnData.size() >= ullMemToAcquire);

for (auto ullOffsetData = 0ULL; ullOffsetData <= ullChunkMaxOffset; ullOffsetData += sizeof(__m128i)) {
if ((ullOffsetData + sizeof(__m128i)) <= ullChunkMaxOffset) {
Expand Down Expand Up @@ -2099,6 +2101,7 @@ auto CHexDlgSearch::SearchFuncFwdByte2(const SEARCHFUNCDATA& refSearch)->FINDRES
for (auto itChunk = 0ULL; itChunk < ullMemChunks; ++itChunk) {
const auto spnData = pHexCtrl->GetData({ ullOffsetSearch, ullMemToAcquire });
assert(!spnData.empty());
assert(spnData.size() >= ullMemToAcquire);

//Next cycle offset is "sizeof(__m128i) - 1", to get the data that crosses the vector.
for (auto ullOffsetData = 0ULL; ullOffsetData <= ullChunkMaxOffset; ullOffsetData += (sizeof(__m128i) - 1)) {
Expand Down Expand Up @@ -2176,6 +2179,7 @@ auto CHexDlgSearch::SearchFuncFwdByte4(const SEARCHFUNCDATA& refSearch)->FINDRES
for (auto itChunk = 0ULL; itChunk < ullMemChunks; ++itChunk) {
const auto spnData = pHexCtrl->GetData({ ullOffsetSearch, ullMemToAcquire });
assert(!spnData.empty());
assert(spnData.size() >= ullMemToAcquire);

//Next cycle offset is "sizeof(__m128i) - 3", to get the data that crosses the vector.
for (auto ullOffsetData = 0ULL; ullOffsetData <= ullChunkMaxOffset; ullOffsetData += (sizeof(__m128i) - 3)) {
Expand Down Expand Up @@ -2261,6 +2265,8 @@ auto CHexDlgSearch::SearchFuncBack(const SEARCHFUNCDATA& refSearch)->FINDRESULT
for (auto itChunk = ullMemChunks; itChunk > 0; --itChunk) {
const auto spnData = pHexCtrl->GetData({ ullOffsetSearch, ullMemToAcquire });
assert(!spnData.empty());
assert(spnData.size() >= ullMemToAcquire);

for (auto llOffsetData = static_cast<LONGLONG>(ullChunkMaxOffset); llOffsetData >= 0;
llOffsetData -= llStep * LOOP_UNROLL_SIZE) { //llOffsetData might be negative.
//First memory comparison is always unconditional.
Expand Down

0 comments on commit e5df4f2

Please sign in to comment.