ComputerCraft

ComputerCraft

21M Downloads

[1.78] fs.find performance issues

SquidDev opened this issue ยท 0 comments

commented

The copy, delete and move programs use fs.find to perform actions on files. However fs.find still searches the entire computer's filesystem even when a non wildcard argument is specified. For computers with a large number of files this can lead to a large delay.

Version
Tested in CC 1.78, but I'd expect this occurs in every version featuring fs.find.

Expected results
A non wildcard pattern (not containing *) would simply check if the file exists.

Reproduction steps

local start = os.clock()
fs.find("rom")
print("Took: " .. (os.clock() - start)) -- Takes about 2 seconds on my computer

This only really matters when the computer has a lot of files - there are about 2500 on my computer.

Copied from this issue

A further enhancement might be to start searching from the last folder before the wildcard.