Skip to content
This repository has been archived by the owner on Jun 17, 2023. It is now read-only.

Add a "fast" mode that leverages modification times #84

Open
JohnC32 opened this issue Sep 30, 2022 · 0 comments
Open

Add a "fast" mode that leverages modification times #84

JohnC32 opened this issue Sep 30, 2022 · 0 comments

Comments

@JohnC32
Copy link

JohnC32 commented Sep 30, 2022

ztree-diff is quite slow and not really usable on any sizable directory. Try running ztree-diff on a directory trees containing 100k files. A solution to this is to add a "fast" mode that relies on modification times and file modes. If the modification times differ or the file modes differ, then the file is different.

If you walk the directory tree an note the file modification times (mtimes), you can then compare the mtimes to see if the files differ. Also record the file modes and record if they differ. This information can then be used to generate the tree in emacs. When you expand a node that is different, you'd then run the true diff.

Also, when constructing the directory tree, for subdirectories that have no modifications, don't embed the contents in the emacs buffer. Rather show the subdirectory unexpanded and when you tab to expand the subdirectory, read the contents from the disk.

This mode needs to be opted in because this mtimes / modes check is not 100% robust. For example, one can write a small program that swaps bytes in a file and rests the file mtime. However, all "normal" development tools such as emacs, when they write a file update the mtime.

If you add this feature, I suspect many will be quite happy because it will make ztree faster than any alternative in emacs or outside of emacs that I'm aware of.

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

No branches or pull requests

1 participant