Refactor: Reduce File Browser Sorting #119103
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#119103
Loading…
Reference in New Issue
No description provided.
Delete Branch "Harley/blender:FileSorting"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Eliminate multiple worst-case scenario file list sorting.
This sounds improbable, so this needs some explanation.
On my Windows computer, when we ask for a directory file listing using API call
FindNextFileW
the items come out in alphabetical order (for NTFS and CDFS). So the list is A-ZBut when we are using that function to assemble the list - in
bli_builddir
- we add each item using addhead so the list becomes alphabetically backwards . Z-AOnce that is done we call qsort - also in
bli_builddir
- on the list to make it (naturally) alphabetically forward (and also put folders first). Because of the previous step we have made this sort almost as difficult as possible. A-ZNow that we have this alphabetical list we then load that into file browser lists, but we do so by going through the list in reverse order - in
filelist_readjob_list_dir
. Z-AAfter this the file listings are then sorted again as the user wishes. And if this is forward alpha order then we are again making this sort as difficult as possible. But now finally A-Z
So A-Z -> Z-A -> A-Z -> Z-A -> A-Z
This PR keeps the items in order before sorting in bli_builddir, then processes the items in order in filelist_readjob_list_dir, eliminating the reversals.
Note that I have reversed the processing order inside
filelist_readjob_list_dir
instead of merely changing a single addtail to an addhead. This is because there could (later) be utility in going through the list in order, especially since it is sorted. For example if we ever want to collapse image sequences.First of all, nice find! Improving this does seem nice. And if there's sorting going on after every step, changing the order of the lists in intermediate cases should matter.
Two main thoughts though:
while (i--)
style for loop, there isn't much improvement. If it's performance, it would be good to include some performance numbers in a large directory or something.@ -3141,0 +3136,4 @@
entries_num++;
}
if (files) {
It looks like moving the
if (files)
check is an unrelated cleanup? The diff would be clearer without that.@HooglyBoogly
All good points. I updated this PR so that it is the minimum changes to stop the list reversals.
There really isn't anything here that would be a measurable performance change in regular usage. I was only amused while looking around in there.
My only motivation was in taking some notes regarding a right-click select suggestion and wanted to remind myself at where would would need sorting. At a place I expected an unsorted order I saw a reversed alpha natural sort so followed the flow from the OS on through.
Okay, maybe this is a party-pooper stance, but if there is no performance gain and no improvement in code quality, I don't get the point of this PR. I think generally each commit should have a clear motivation-- as it stands this one doesn't really.
No worries.
Pull request closed