Version.cpp: Simplify Version::parse by using const auto& current_char

Signed-off-by: Edgars Cīrulis <edgarsscirulis@gmail.com>
This commit is contained in:
Edgars Cīrulis 2023-01-15 17:07:44 +02:00
parent de11017552
commit 198139feb4
No known key found for this signature in database
GPG Key ID: 307C4E4663F1FCC3

View File

@ -79,16 +79,17 @@ void Version::parse()
return (( lastChar.isLetter() && currentChar.isDigit() ) || (lastChar.isDigit() && currentChar.isLetter()) );
};
for (int i = 0; i < m_string.size(); ++i) {
if(m_string[i].isDigit() || m_string[i].isLetter()){
if(i>0 && classChange(m_string[i-1], m_string[i])){
const auto& current_char = m_string.at(i);
if(current_char.isDigit() || current_char.isLetter()){
if(i>0 && classChange(m_string.at(i-1), current_char)){
if(!currentSection.isEmpty()){
m_sections.append(Section(currentSection));
}
currentSection = "";
}
currentSection += m_string[i];
currentSection += current_char;
}
else if(m_string[i] == '.' || m_string[i] == '-' || m_string[i] == '_'){
else if(current_char == '.' || current_char == '-' || current_char == '_'){
if(!currentSection.isEmpty()){
m_sections.append(Section(currentSection));
}