mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
refactor(console): prepare for noUncheckedIndexedAccess
(#4269)
This commit is contained in:
parent
9d0317a5be
commit
b77b51aa70
@ -32,7 +32,7 @@ export function runLengthDecode({ d, r }: { d: string; r: string }) {
|
||||
let out = "";
|
||||
|
||||
for (const [i, ch] of [...runLengths].entries()) {
|
||||
out += data[i].repeat(ch.codePointAt(0)!);
|
||||
out += data[i]!.repeat(ch.codePointAt(0)!);
|
||||
}
|
||||
|
||||
return Uint8Array.from([...out].map((x) => x.codePointAt(0)!));
|
||||
|
@ -8,9 +8,11 @@ let tables: Uint8Array[] | null = null;
|
||||
function lookupWidth(cp: number) {
|
||||
if (!tables) tables = data.tables.map(runLengthDecode);
|
||||
|
||||
const t1Offset = tables[0][(cp >> 13) & 0xff];
|
||||
const t2Offset = tables[1][128 * t1Offset + ((cp >> 6) & 0x7f)];
|
||||
const packedWidths = tables[2][16 * t2Offset + ((cp >> 2) & 0xf)];
|
||||
const t1Offset = (tables[0] as Uint8Array)[(cp >> 13) & 0xff] as number;
|
||||
const t2Offset =
|
||||
(tables[1] as Uint8Array)[128 * t1Offset + ((cp >> 6) & 0x7f)] as number;
|
||||
const packedWidths =
|
||||
(tables[2] as Uint8Array)[16 * t2Offset + ((cp >> 2) & 0xf)] as number;
|
||||
|
||||
const width = (packedWidths >> (2 * (cp & 0b11))) & 0b11;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user