write_pbm_image: use QBAV more

to reduce allocations

Change-Id: I99351a8042a315b4b0742567ba77082b576cbece
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Anton Kudryavtsev 2023-09-15 14:31:50 +03:00
parent ec7f06fa62
commit 694f4f3a3b

View File

@ -265,13 +265,12 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q
return true; return true;
} }
static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QByteArray &sourceFormat) static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, QByteArrayView sourceFormat)
{ {
QByteArray str; QByteArray str;
QImage image = sourceImage; QImage image = sourceImage;
QByteArray format = sourceFormat; const QByteArrayView format = sourceFormat.left(3); // ignore RAW part
format = format.left(3); // ignore RAW part
bool gray = format == "pgm"; bool gray = format == "pgm";
if (format == "pbm") { if (format == "pbm") {