perf(fs): don't canonicalize path when opening file if --allow-all is passed (#28716)

Fixes #28702.

Super artificial benchmark:

```ts
const perf = performance;

async function asyncOpen() {
  const start = perf.now();
  for (let i = 0; i < 100_000; i++) {
    const file = await Deno.open("./foo.txt");
    file.close();
  }
  const end = perf.now();
  console.log(end - start);
}

function syncOpen() {
  const start = perf.now();
  for (let i = 0; i < 100_000; i++) {
    const file = Deno.openSync("./foo.txt");
    file.close();
  }
  const end = perf.now();
  console.log(end - start);
}

if (Deno.args[0]?.trim() === "async") {
  await asyncOpen();
} else {
  syncOpen();
}
```

Results (average of 10 for each):

```
deno sync               1785.59
deno-this-pr sync       491.69
deno async              1839.71
deno-this-pr async      528.78
```

---------

Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
This commit is contained in:
Nathan Whitaker 2025-04-29 16:16:24 -07:00 committed by GitHub
parent 1a171f10df
commit c22d17824b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 205 additions and 134 deletions

View file

@ -61,7 +61,7 @@ impl<TSys: DenoLibSys> NpmRegistryReadPermissionChecker<TSys> {
Ok(Cow::Borrowed(path))
} else {
permissions
.check_read_path(path)
.check_read_path(Cow::Borrowed(path))
.map_err(JsErrorBox::from_err)
}
}
@ -112,7 +112,7 @@ impl<TSys: DenoLibSys> NpmRegistryReadPermissionChecker<TSys> {
}
permissions
.check_read_path(path)
.check_read_path(Cow::Borrowed(path))
.map_err(JsErrorBox::from_err)
}
}