Skip to content

Commit

Permalink
rename ChoiceReplacer field
Browse files Browse the repository at this point in the history
  • Loading branch information
Владимир Чиж authored and Владимир Чиж committed Aug 11, 2024
1 parent 3f72a19 commit 0ca78a6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions srcbpatch/streamreplacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class ChoiceReplacer final : public ReplacerWithNext
vector<ChoiceReplacerPair> rpairs_;

mutable size_t cachedAmount_ = 0; // we cache this amount of data
mutable size_t indexOfCached_ = 0; // at this index from rpairs_
mutable size_t indexOfPartialMatch = 0; // at this index from rpairs_, represents last partial match

// this is used to hold temporary data while the logic is
// looking for the new beginning of the cached value
Expand All @@ -287,7 +287,7 @@ void ChoiceReplacer::ProcessLastCharacter(const char toProcess) const
while (cachedAmount_ > 0)
{
bool foundFullMatch = false;
for (size_t i = indexOfCached_; i < rpairs_.size(); ++i)
for (size_t i = indexOfPartialMatch; i < rpairs_.size(); ++i)
{
auto [partialMatch, fullMatch, srcMatchedLength, destStringIdx] = CheckMatch(i);
if (fullMatch)
Expand All @@ -314,7 +314,7 @@ void ChoiceReplacer::ProcessCharacter(const char toProcess) const
buffer_[cachedAmount_++] = toProcess;
while (cachedAmount_ > 0)
{
for (size_t i = indexOfCached_; i < rpairs_.size(); ++i)
for (size_t i = indexOfPartialMatch; i < rpairs_.size(); ++i)
{
auto [partialMatch, fullMatch, srcMatchedLength, matchPairIdx] = CheckMatch(i);
if (fullMatch)
Expand All @@ -325,7 +325,7 @@ void ChoiceReplacer::ProcessCharacter(const char toProcess) const
}
if (partialMatch)
{
indexOfCached_ = matchPairIdx;
indexOfPartialMatch = matchPairIdx;
return;
}
}
Expand All @@ -341,7 +341,7 @@ inline void ChoiceReplacer::MakeReplace(span<const char> target) const
{
pNext_->DoReplacements(elem, false);
}
indexOfCached_ = 0;
indexOfPartialMatch = 0;
}

inline void ChoiceReplacer::CleanTheCache(size_t srcMatchedLength) const
Expand Down

0 comments on commit 0ca78a6

Please sign in to comment.