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:
commit
fc68a9f3ee
@ -151,7 +151,13 @@ class FlateStream extends DecodeStream {
|
|||||||
|
|
||||||
async getImageData(length, _decoderOptions) {
|
async getImageData(length, _decoderOptions) {
|
||||||
const data = await this.asyncGetBytes();
|
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() {
|
async asyncGetBytes() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user