Merge pull request #19958 from calixteman/rm_useless_subarray_flate_stream

Don't create a useless subarray when getting image data from a flate stream
This commit is contained in:
calixteman 2025-05-19 19:29:25 +02:00 committed by GitHub
commit fc68a9f3ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -151,7 +151,13 @@ class FlateStream extends DecodeStream {
async getImageData(length, _decoderOptions) {
const data = await this.asyncGetBytes();
return data?.subarray(0, length) || this.getBytes(length);
if (!data) {
return this.getBytes(length);
}
if (data.length <= length) {
return data;
}
return data.subarray(0, length);
}
async asyncGetBytes() {