migrate QStringRef -> QStringView (#425)

This commit is contained in:
Cyano Hao 2024-05-14 08:38:22 +08:00 committed by GitHub
parent b8567f09cb
commit 43e795e791
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 8 additions and 7 deletions

View File

@ -148,7 +148,7 @@ int Compiler::getLineNumberFromOutputLine(QString &line)
pos = line.indexOf(',');
}
if (pos>=0) {
result = line.midRef(0,pos).toInt();
result = QStringView(line.data(), pos).toInt();
if (result > 0)
line.remove(0,pos+1);
} else {
@ -168,7 +168,7 @@ int Compiler::getColunmnFromOutputLine(QString &line)
pos = line.indexOf(',');
}
if (pos>=0) {
result = line.midRef(0,pos).toInt();
result = QStringView(line.data(), pos).toInt();
if (result > 0)
line.remove(0,pos+1);
}

View File

@ -3449,7 +3449,7 @@ void CppParser::handlePreprocessor()
// Mention progress to user if we enter a NEW file
bool ok;
int line = s.midRef(delimPos+1).toInt(&ok);
int line = QStringView(s.begin() + delimPos + 1, s.end()).toInt(&ok);
if (line == 1) {
mFilesScannedCount++;
mFilesToScanCount++;

View File

@ -1037,7 +1037,7 @@ QStringList CppPreprocessor::removeComments(const QStringList &text)
currentType=ContentType::Other;
break;
case ContentType::RawString:
if (line.midRef(0,pos).endsWith(')'+delimiter))
if (QStringView(line.data(), pos).endsWith(')'+delimiter))
currentType = ContentType::Other;
break;
case ContentType::Other:

View File

@ -194,7 +194,7 @@ QString CppTokenizer::getNextToken(TokenType *pTokenType)
int delimPos = result.lastIndexOf(':');
if (delimPos >= 0) {
bool ok;
mCurrentLine = result.midRef(delimPos+1).toInt(&ok)-1; // fCurrLine is 0 based
mCurrentLine = QStringView(result.begin() + delimPos + 1, result.end()).toInt(&ok)-1; // fCurrLine is 0 based
}
}
done = (result != "");

View File

@ -252,7 +252,7 @@ QString QConsole::selText()
QString s = mContents.getLine(Last);
if (Last == mContents.lines())
s+= this->mCommand;
result += s.leftRef(ColTo);
result.append(s.data(), ColTo);
return result;
}
}

View File

@ -4497,7 +4497,8 @@ QString QSynEdit::selText() const
result += mDocument->getLine(i);
result+=lineBreak();
}
result += mDocument->getLine(lastLine).leftRef(charTo-1);
const QString &line = mDocument->getLine(lastLine);
result.append(line.data(), charTo-1);
return result;
}
}