https://gitlab.synchro.net/main/sbbs/-/commit/0bc5f31da7f613b4db3f4cec
Modified Files:
exec/load/filebase.js webv4/lib/files.js
Log Message:
Build file base paths without a per-file lookup
OldFileBase() called FileBase.get_path() for each file. get_path() finds
the file by name with a linear scan of the directory's index, so listing a directory was O(n^2) in its file count. Every webv4 download paid this cost too, since api/files.ssjs builds the whole list to find one file.
A file's path is its directory's path plus its name, which is all
getfilepath() builds, so build it directly. file_getcase() does the same case-correcting existence check that get_path() did and returns undefined
for a missing file, as before.
OldFileBase() now also returns each file's size from get_list(), and
webv4's listFiles() uses it instead of calling file_size() twice per file.
For a directory of 3,607 files, measured on a Windows host that reaches
the file base over SMB, where each file stat costs about 3 ms: the
get_path() calls took about 14 seconds and the file_size() calls about 22;
the file_getcase() calls that replace them take 7. Locally on Linux, the
whole listing drops from 2.6 to 0.1 seconds. Paths and sizes are identical
for every file.
Co-Authored-By: Claude Opus 5.5 <
noreply@anthropic.com>
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net