Don't create a useless subarray when getting image data from a flate stream
This commit is contained in:
parent
2b9f621087
commit
3ecbef516d
@ -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() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user