Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: fs optimizations - part 1 #15873

Merged
merged 24 commits into from
Sep 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix unix
  • Loading branch information
littledivy committed Sep 15, 2022
commit 8f4800c3e83abd704ab09051b50d92da4b2becfb
16 changes: 10 additions & 6 deletions runtime/js/30_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,11 @@
}

function createByteStruct(types) {
// types can be "date", "bool" or "u64"
// types can be "date", "bool" or "u64".
// `?` prefix means optional on windows.
let offset = 0;
let str = "return {";
let str =
'const unix = Deno.build.os === "darwin" || Deno.build.os === "linux"; return {';
for (let [name, type] of ObjectEntries(types)) {
const optional = type.startsWith("?");
if (optional) type = type.slice(1);
Expand All @@ -198,9 +200,11 @@
if (!optional) {
str += `${name}: view[${offset}] + view[${offset + 1}] * 2**32,`;
} else {
str += `${name}: (view[${offset}] + view[${offset + 1}] * 2**32) ${
!unix ? "|| null" : ""
},`;
str += `${name}: (unix ? (view[${offset}] + view[${
offset + 1
}] * 2**32) : (view[${offset}] + view[${
offset + 1
}] * 2**32) || null),`;
}
} else if (type == "date") {
str +=
Expand All @@ -216,7 +220,6 @@
return [new Function("view", str), new Uint32Array(offset)];
}

const unix = build.os === "darwin" || build.os === "linux";
const [statStruct, statBuf] = createByteStruct({
isFile: "bool",
isDirectory: "bool",
Expand All @@ -237,6 +240,7 @@
});

function parseFileInfo(response) {
const unix = build.os === "darwin" || build.os === "linux";
return {
isFile: response.isFile,
isDirectory: response.isDirectory,
Expand Down