js-mdict icon indicating copy to clipboard operation
js-mdict copied to clipboard

lookup 方法 nextStart 计算疑问

Open tonyzhou1890 opened this issue 3 years ago • 0 comments

    const i = record.idx;
    const list = record.list;
    const rid = this._reduceRecordBlock(list[i].recordStartOffset);
    const nextStart =
      i + 1 >= list.length
        ? this._recordBlockStartOffset +
          this.recordBlockInfoList[this.recordBlockInfoList.length - 1]
            .decompAccumulator +
          this.recordBlockInfoList[this.recordBlockInfoList.length - 1]
            .decompSize
        : list[i + 1].recordStartOffset;

list 是当前块的单词列表,但当最后一个单词的时候,偏移值却是根据最后一个 block 计算的。虽然最后查询结果没问题——_decodeRecordBlockByRBID 是截取的当前块的数据,就算 nextStart 超出也没关系。 不确定 nextStart 的计算是否是有意这么写的。

tonyzhou1890 avatar Dec 06 '21 06:12 tonyzhou1890