Moved variables closer to their first usage point

This commit is contained in:
Nicholas Baron 2019-04-17 00:01:02 -07:00
commit 5f060696b2

View file

@ -266,11 +266,8 @@ bool CopyPasteManager::ExpressionRegExMatch(vector<wstring> operands, ViewMode m
return false; return false;
} }
bool expMatched = true;
vector<wregex> patterns{}; vector<wregex> patterns{};
const auto [maxOperandLength, maxOperandValue] = GetMaxOperandLengthAndValue(mode, modeType, programmerNumberBase, bitLengthType);
if (mode == ViewMode::Standard) if (mode == ViewMode::Standard)
{ {
patterns.assign(standardModePatterns.begin(), standardModePatterns.end()); patterns.assign(standardModePatterns.begin(), standardModePatterns.end());
@ -288,6 +285,9 @@ bool CopyPasteManager::ExpressionRegExMatch(vector<wstring> operands, ViewMode m
patterns.assign(unitConverterPatterns.begin(), unitConverterPatterns.end()); patterns.assign(unitConverterPatterns.begin(), unitConverterPatterns.end());
} }
const auto [maxOperandLength, maxOperandValue] = GetMaxOperandLengthAndValue(mode, modeType, programmerNumberBase, bitLengthType);
bool expMatched = true;
for (const auto& operand : operands) for (const auto& operand : operands)
{ {
// Each operand only needs to match one of the available patterns. // Each operand only needs to match one of the available patterns.
@ -494,8 +494,7 @@ size_t CopyPasteManager::StandardScientificOperandLength(const wstring& operand)
size_t CopyPasteManager::ProgrammerOperandLength(const wstring& operand, int numberBase) size_t CopyPasteManager::ProgrammerOperandLength(const wstring& operand, int numberBase)
{ {
size_t len = operand.length();
vector<wstring> prefixes{}; vector<wstring> prefixes{};
vector<wstring> suffixes{}; vector<wstring> suffixes{};
switch (numberBase) switch (numberBase)
@ -526,6 +525,8 @@ size_t CopyPasteManager::ProgrammerOperandLength(const wstring& operand, int num
wstring operandUpper = operand; wstring operandUpper = operand;
transform(operandUpper.begin(), operandUpper.end(), operandUpper.begin(), towupper); transform(operandUpper.begin(), operandUpper.end(), operandUpper.begin(), towupper);
size_t len = operand.length();
// Detect if there is a suffix and subtract its length // Detect if there is a suffix and subtract its length
// Check suffixes first to allow e.g. "0b" to result in length 1 (value 0), rather than length 0 (no value). // Check suffixes first to allow e.g. "0b" to result in length 1 (value 0), rather than length 0 (no value).
for (const auto& suffix : suffixes) for (const auto& suffix : suffixes)