mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-06-03 17:08:08 -04:00
kimg_rgb: optimize away QRegExp and QString::fromLocal8Bit.
Summary: The code is even simpler this way. Found by using heaptrack. Test Plan: the unittest for rgb still passes. Reviewers: cfeck Reviewed By: cfeck Subscribers: jtamate, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D15890
This commit is contained in:
parent
1db1b94657
commit
f485719012
@ -686,8 +686,8 @@ bool RGBHandler::canRead(QIODevice *device)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 oldPos = device->pos();
|
const qint64 oldPos = device->pos();
|
||||||
QByteArray head = device->readLine(64);
|
const QByteArray head = device->readLine(64);
|
||||||
int readBytes = head.size();
|
int readBytes = head.size();
|
||||||
|
|
||||||
if (device->isSequential()) {
|
if (device->isSequential()) {
|
||||||
@ -699,10 +699,7 @@ bool RGBHandler::canRead(QIODevice *device)
|
|||||||
device->seek(oldPos);
|
device->seek(oldPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QRegExp regexp(QLatin1String("^\x01\xda\x01[\x01\x02]"));
|
return head.size() >= 4 && head.startsWith("\x01\xda\x01") && (head[3] == 1 || head[3] == 2);
|
||||||
QString data(QString::fromLocal8Bit(head));
|
|
||||||
|
|
||||||
return data.contains(regexp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user