================
@@ -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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to