mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 10:52:56 +00:00
use immutable strings table in extractEncodingDecl()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
55ce388fc0
commit
ecf37fb164
1 changed files with 12 additions and 4 deletions
|
@ -1457,12 +1457,20 @@ void QXmlInputSource::fetchData()
|
|||
#ifndef QT_NO_TEXTCODEC
|
||||
static QString extractEncodingDecl(const QString &text, bool *needMoreText)
|
||||
{
|
||||
int l = text.length();
|
||||
QString snip = QString::fromLatin1("<?xml").left(l);
|
||||
if (l > 0 && !text.startsWith(snip))
|
||||
static const QLatin1String snipsTbl[] {
|
||||
QLatin1String("<"),
|
||||
QLatin1String("<?"),
|
||||
QLatin1String("<?x"),
|
||||
QLatin1String("<?xm"),
|
||||
QLatin1String("<?xml"),
|
||||
};
|
||||
|
||||
const int l = text.length();
|
||||
const int snipindex = qBound(0, l, 5) - 1;
|
||||
if (l > 0 && !text.startsWith(snipsTbl[snipindex]))
|
||||
return QString();
|
||||
|
||||
int endPos = text.indexOf(QLatin1Char('>'));
|
||||
const int endPos = text.indexOf(QLatin1Char('>'));
|
||||
if (endPos == -1) {
|
||||
*needMoreText = l < 255; // we won't look forever
|
||||
return QString();
|
||||
|
|
Loading…
Add table
Reference in a new issue