On 20 Jan, Bob Latham wrote in message
Post by Bob Latham
I'm playing with some assembler code to scan directory and sub directories
for unwanted files and to list files I do want. I do have working code but
I think it could be made faster and need advice.
Currently it uses GBPB10 to catalogue a directory. I look through the
objects one at a time looking for another directory. When found a
directory is added to the path, loops back to scan again. The code does
all the work when R4=-1 and I've reached the end of the deepest directory.
It is on the way back up that things get done.
I think my code is a bit slow because I scan with R3=1 so I get one object
at a time. I do this because I'm unsure about buffer sizes and how to
handle large amounts of data with R3 any bigger.
That's almost certainly your main problem. There's an overhead to calling
OS_GBPB, so you're far better off providing a "big" buffer and getting more
results back for each attempt.
The only issue is that with recursion, you need to start stacking your
buffers as well as everything else, since you need to be able to come back
and process any remaining items from a buffer after dropping into a
subdirectory and calling OS_GBPB on that with a new buffer. This is what
Locate 2 does, but being written in C it has the advantage of being able to
use an array of structs to handle the memory allocation headache.
The other thing that makes a difference, if you're multitasking, is getting
the timeslicing right. Locate 1 returned control to the Wimp at fixed points
in the scan cycle (whenever it dropped back out of a directory, IIRC).
Locate 2 returns after fixed time periods, processing as many directories as
it can each time.
Between these two optimisations, Locate 2 turned out to be significantly
faster than Locate 1.
Post by Bob Latham
I did wonder if there is a quicker way to find directories within
directories than looking at one object at a time to see what I get. I feel
there should be something similar to pathname wild cards so before the
scan the OS knows I only want directories but the PRM doesn't list that as
far as I can see.
No, you just grab everything and read through it, checking the object types
as you go.
One final random observation: stick with OS_GBPB 10. 11 and 12 look
interesting, but feedback from Locate users over the years showed that
several fairly common third-party image filing systems (which I won't name
and shame) don't support them.
Steve Fryatt - Leeds, England