:/ sadly this is not new...

see http://code.google.com/p/pharo/issues/detail?id=5316
and http://code.google.com/p/cog/issues/detail?id=73

and I mentioned it in an earlier thread. if you want you can write a fix for 
this
by using the other file primitives (I don't remember the exact name right now)
where you access the entries by name instead of by index, which of course avoids
looping internally again. I wrote a fix for this under OSX where they weren't 
implemented... so basically it should work right ahead!

btw this implementation is super fun!!

Filelist loops  => n
DiskStore loops => n*(n/2)  "in average you loop until you find the proper 
entry)
Primitive loops => n*(n/2)*n "again since you access the stuff by index"



best
cami


On 2012-05-10, at 09:56, Mariano Martinez Peck wrote:

> Thanks Nicolas. I would appreciate any effort in this directory since I also 
> have a 10gb package-cache and yes, I know it is slow.
> If you can provive a slice :)
> 
> On Thu, May 10, 2012 at 9:44 AM, Stéphane Ducasse <[email protected]> 
> wrote:
> :)
> 
> indeed. Imagine my 10 GB package cache.
> 
> Stef
> 
> 
> On May 10, 2012, at 12:18 AM, Nicolas Cellier wrote:
> 
> > The efficiency of FileList>>listForPattern: is something which should
> > deserve a bit more care.
> >
> > It tries to sort the files, for example by name, but wants to display
> > directory first
> >       ^ [ :x :y | |xIsDir|
> >                       ((xIsDir := x isDirectory) = y isDirectory)
> >                               ifTrue: [   x basename <= y basename  ]
> >                               ifFalse: [
> >                                       "directories always precede files"
> >                                       xIsDir ]]
> >
> > Alas, this isDirectory test cost you an arm:
> >
> > FileReference>>isDirectory
> >       ^ filesystem isDirectory: path
> >
> > FileSystem>>isDirectory: aResolvable
> >       "Resolve the argument, and answer true if the result refers
> >       to a directory, false if it refers to a file or doesn't exist."
> >
> >       ^ store isDirectory: (self resolve: aResolvable)
> >
> > FileSystemStore>>isDirectory: aPath
> >       aPath isRoot ifTrue: [ ^ true ].
> >       self
> >               nodeAt: aPath
> >               ifPresent: [ :entry | ^ self basicIsDirectory: entry ]
> >               ifAbsent: [ ^ false ].
> >
> > DiskStore>>nodeAt: aPath ifPresent: presentBlock ifAbsent: absentBlock
> >       | name|
> >       aPath isRoot ifTrue: [ ^ presentBlock value: self rootNode ].
> >       "| encodedPath encodedBasename entry |
> >       encodedPath := Primitives encode: (self stringFromPath: aPath parent).
> >       encodedBasename := Primitives encode: aPath basename.
> >       entry := Primitives lookupDirectory: encodedPath filename: 
> > encodedBasename.
> >       ^ entry == #badDirectoryPath
> >               ifTrue: absentBlock
> >               ifFalse: [
> >                       entry at: 1 put: aPath basename.
> >                       presentBlock value: entry ]."
> >       name := aPath basename.
> >       self
> >               directoryAt: aPath parent
> >               ifAbsent: absentBlock
> >               nodesDo:
> >                       [ :entry |
> >                       (self filename: (entry at: 1) matches: name)
> >                               ifTrue: [ ^ presentBlock value: entry ] ].
> >       ^ absentBlock value
> >
> > Arghh, it scans the whole parent directory again!
> > If sort is O(n log n), then we transform it into O(2 n^2 log n).
> >
> > Try to browse your package-cache if you're not a chicken.
> > Seriously, it's unusable...
> >
> > Nicolas
> >
> 
> 
> 
> 
> 
> -- 
> Mariano
> http://marianopeck.wordpress.com
> 


Reply via email to