[clang-tools-extra] [clang-doc] switched from using relative to absolute paths (PR #93281)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 29 09:48:50 PDT 2024
================
@@ -1,12 +1,19 @@
function genLink(Ref) {
var Path = `${window.location.protocol}//${window.location.host}/${Ref.Path}`;
+ var isFileProtocol = window.location.protocol.startsWith("file");
+ // we treat the file paths different depending on if we're
+ // serving via a http server or viewing from a local
+ if (isFileProtocol) {
+ Path = `${window.location.protocol}//${RootPath}/${Ref.Path}`;
+ }
----------------
ilovepi wrote:
Maybe it makes sense to initialize `Path` w/ the ternary operator? Also, I'm now wondering if we really want `var` here or if this should be declared w/ `let`.
This should improve the performance slightly, since `Path` is only initialized once, and saves at least 1 allocation on the JS heap. My JS is pretty weak though, so if I'm wrong on that, I'm happy to defer.
```suggestion
let isFileProtocol = window.location.protocol.startsWith("file");
// We treat the file paths different depending on if we're
// serving via a http server or viewing from a local.
var Path = isFileProtocol ? `${window.location.protocol}//${RootPath}/${Ref.Path}` :`${window.location.protocol}//${window.location.host}/${Ref.Path}`;
```
https://github.com/llvm/llvm-project/pull/93281
More information about the cfe-commits
mailing list