ImageGlass icon indicating copy to clipboard operation
ImageGlass copied to clipboard

ReloadImageList is sub-optimal

Open fire-eggs opened this issue 5 years ago • 0 comments

Windows 10 -> viewing images in a folder across the network. "Include child folders" is ON. The folder in question had 22,184 files and 317 folders.

Behavior:

  1. Ran IG.
  2. Opened an image at the top of the tree.
  3. IG showed images and could be used in 1 second or so.
  4. Goto settings, change sort order. [Sufficient to switch sort-by-name from Ascending to Descending, or visa-versa]. Save and exit.

At this point, ImageGlass takes 12+ seconds to come back to life.

Running Performance Profiler, the CPU hotspot identified is GetDistinctDirsFromPaths. Specifically, the call to File.Exists().

Debugging: A. On the initial call, GetDistinctDirsFromPaths is given a single path, the original single file opened. B. On the second call (as invoked from ReloadImageList), GetDistinctDirsFromPaths is given a pathlist containing every file in the image list!

File.Exists() is a relatively expensive call, especially across the network.

A simple resort of the existing list should not require a full verification of every single file and path.

fire-eggs avatar Jul 19 '19 23:07 fire-eggs