buffer.ts ×3

Frontier kind: Code frontier

unlabeled · c_12e5fd5d302e

771 tests · 3937 LOC · 21 files · introduces 0 tests · 37 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
3 ranges37 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
558 ranges3937 lines · 21 files · Browse complete extent
All tests (intent)
771 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 37 introduced LOC across 3 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/base/common/buffer.ts 37 introduced LOC · 3 ranges

Open complete file

365 /** Decodes base64 to a uint8 array. URL-encoded and unpadded base64 is allowed. */
366 export function decodeBase64(encoded: string) {
367 > let building = 0; buffer.ts
368 > let remainder = 0;
369 > let bufi = 0;
370 >
371 > // The simpler way to do this is `Uint8Array.from(atob(str), c => c.charCodeAt(0))`,
372 > // but that's about 10-20x slower than this function in current Chromium versions.
373 >
374 > const buffer = new Uint8Array(Math.floor(encoded.length / 4 * 3));
375 > const append = (value: number) => {
376 > switch (remainder) {
377 > case 3:
378 > buffer[bufi++] = building | value;
379 > remainder = 0;
380 > break;
381 > case 2:
382 > buffer[bufi++] = building | (value >>> 2);
383 > building = value << 6;
384 > remainder = 3;
385 > break;
386 > case 1:
387 > buffer[bufi++] = building | (value >>> 4);
388 > building = value << 4;
389 > remainder = 2;
390 > break;
391 > default:
392 > building = value << 2;
393 > remainder = 1;
394 > }
395 > };
396 >
397 > for (let i = 0; i < encoded.length; i++) {
398 > const code = encoded.charCodeAt(i);
399 > // See https://datatracker.ietf.org/doc/html/rfc4648#section-4
400 > // This branchy code is about 3x faster than an indexOf on a base64 char string.
401 > if (code >= 65 && code <= 90) {
402 append(code - 65); // A-Z starts ranges from char code 65 to 90
403 > } else if (code >= 97 && code <= 122) { buffer.ts
404 append(code - 97 + 26); // a-z starts ranges from char code 97 to 122, starting at byte 26
405 } else if (code >= 48 && code <= 57) {
414 throw new SyntaxError(`Unexpected base64 character ${encoded[i]}`);
415 }
416 > } buffer.ts
417
418 const unpadded = bufi;