Skip to content

Decompression speed解压速度 #353

Answered by 0f-0b
nenge123 asked this question in Q&A
Aug 14, 2022 · 4 comments · 3 replies
Discussion options

You must be logged in to vote

使用了 Uint8ArrayWriter 吗?如果是,那么换成下面的实现或者 BlobWriter 之后,情况有所改善吗?

class Uint8ArrayWriter extends Writer {
  chunks = [];

  writeUint8Array(array) {
    super.writeUint8Array(array);
    this.chunks.push(array);
  }

  getData() {
    const { chunks } = this;
    let size = 0;
    for (const chunk of chunks) {
      size += chunk.length;
    }
    const array = new Uint8Array(size);
    let offset = 0;
    for (const chunk of chunks) {
      array.set(chunk, offset);
      offset += chunk.length;
    }
    return array;
  }
}

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@nenge123
Comment options

@nenge123
Comment options

Answer selected by nenge123
Comment options

You must be logged in to vote
1 reply
@nenge123
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants