check symlink before reading file
authorJoey Hess <joeyh@joeyh.name>
Mon, 14 Jun 2021 15:53:51 +0000 (11:53 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 14 Jun 2021 15:53:51 +0000 (11:53 -0400)
This is faster because when multiple files are in a directory, it gets
cached.

Annex/Link.hs
doc/bugs/significant_performance_regression_impacting_datal/comment_25_5525b58ec94084a926c71f749d1f4233._comment [new file with mode: 0644]

index 50f2717fcbbd87833ceb042153984e73ab20c45a..c305b39bd7113f6f2ea82ddce87bee4b36398742 100644 (file)
@@ -301,7 +301,7 @@ unpaddedMaxPointerSz = 8192
  - symlink does. Avoids a false positive in those cases.
  - -}
 isPointerFile :: RawFilePath -> IO (Maybe Key)
-isPointerFile f = catchDefaultIO Nothing $ do
+isPointerFile f = catchDefaultIO Nothing $
 #if defined(mingw32_HOST_OS)
        checkcontentfollowssymlinks -- no symlinks supported on windows
 #else
@@ -311,13 +311,10 @@ isPointerFile f = catchDefaultIO Nothing $ do
                closeFd
                (\fd -> readhandle =<< fdToHandle fd)
 #else
-       pointercontent <- checkcontentfollowssymlinks
-       if isJust pointercontent
-               then ifM (isSymbolicLink <$> R.getSymbolicLinkStatus f)
-                       ( return Nothing
-                       , return pointercontent
-                       )
-               else return Nothing
+       ifM (isSymbolicLink <$> R.getSymbolicLinkStatus f)
+               ( return Nothing
+               , checkcontentfollowssymlinks
+               )
 #endif
 #endif
   where
diff --git a/doc/bugs/significant_performance_regression_impacting_datal/comment_25_5525b58ec94084a926c71f749d1f4233._comment b/doc/bugs/significant_performance_regression_impacting_datal/comment_25_5525b58ec94084a926c71f749d1f4233._comment
new file mode 100644 (file)
index 0000000..ca226f1
--- /dev/null
@@ -0,0 +1,8 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 25"""
+ date="2021-06-14T15:52:37Z"
+ content="""
+Found an optimisation that sped it up 50%, but this edge case is still 
+`O(N^2)`, so *shrug*.
+"""]]