(v: bigint | number)
| 147 | } |
| 148 | |
| 149 | writeSliInt64(v: bigint | number) { |
| 150 | if (v <= HalfMaxInt32 && v >= HalfMinInt32) { |
| 151 | // write: |
| 152 | // 00xxx -> 0xxx |
| 153 | // 11xxx -> 1xxx |
| 154 | // read: |
| 155 | // 0xxx -> 00xxx |
| 156 | // 1xxx -> 11xxx |
| 157 | this.dataView.setUint32(this.cursor, Number(v) << 1, true); |
| 158 | this.cursor += 4; |
| 159 | } else { |
| 160 | const BIG_LONG_FLAG = 0b1; // bit 0 set, means big long. |
| 161 | this.dataView.setUint8(this.cursor, BIG_LONG_FLAG); |
| 162 | this.cursor += 1; |
| 163 | this.writeVarInt64(BigInt(v)); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * Write signed long using fory Tagged(Small long as int) encoding. |
nothing calls this directly
no test coverage detected