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

Calling test multiple times will add the overhead of making the stat system call multiple times. #53

Open
rnjtranjan opened this issue Jul 6, 2022 · 1 comment
Assignees

Comments

@rnjtranjan
Copy link
Contributor

isAccessible in module Streamly.Coreutils.FileTest
isAccessible :: Tuple3 FileMode FileMode FileMode -> FilePath -> IO FileTest
isAccessible (Tuple3 onr grp oth) path = do
ownerIDMatch <- ownerMatchesEUID
groupIDMatch <- groupMatchesEGID
let ownerPerm = FileTest $ hasMode onr
groupPerm = FileTest $ hasMode grp
otherPerm = FileTest $ hasMode oth
ownerHasPermission <- test path ownerPerm
groupHasPermission <- test path groupPerm
isOwner <- test path ownerIDMatch

@harendra-kumar
Copy link
Member

Calling test multiple times will add the overhead of making the stat system call multiple times. We can write the predicate in a way so that it does not have to use test multiple times. It may possibly require the predicate to be of type a -> m Bool rather the a -> Bool. I will have to look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants