Avoid copying timezone data bytes (#21028)

This was missed in the PR when changing the implementation to use
slices of Uint8Array rather than slices of ArrayBuffer.

Making the function non-async since it's entirely synchronous.
This commit is contained in:
Pranav K 2020-04-20 15:20:35 -07:00 committed by GitHub
parent 2bd662fe0b
commit 202d21431e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 15 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
import { readInt32LE } from "../../BinaryDecoder";
import { decodeUtf8 } from "../../Utf8Decoder";
export async function loadTimezoneData(arrayBuffer: ArrayBuffer) : Promise<void> {
export function loadTimezoneData(arrayBuffer: ArrayBuffer) {
let remainingData = new Uint8Array(arrayBuffer);
// The timezone file is generated by https://github.com/dotnet/blazor/tree/master/src/TimeZoneData.
@ -34,11 +34,10 @@ export async function loadTimezoneData(arrayBuffer: ArrayBuffer) : Promise<void>
Module['FS_createPath']('/zoneinfo', folder, true, true));
for (const [name, length] of manifest) {
const bytes = new Uint8Array(remainingData.slice(0, length));
const bytes = remainingData.slice(0, length);
Module['FS_createDataFile'](`/zoneinfo/${name}`, null, bytes, true, true, true);
remainingData = remainingData.slice(length);
}
}
type ManifestEntry = [string, number];