From: TRANS Date: 2005-10-26T13:12:03+09:00 Subject: Re: Pathname#join is slow (Was: Re: [PATCH] Pathname.exists?()) On 10/25/05, Gavin Sinclair wrote: > On 10/26/05, Ara.T.Howard wrote: > > >>> > > >>> Would a good solution be to implement Pathname in C? > > >> > > >> That certainlu couldn't hurt, > > > > > > No, it would hurt, writing it in C would make it more difficult to understand > > > and change by non-C rubyists. > > > > amen. heavy string manpulation and c do not belong in the same sentence. > > The implementation I had in mind would use the Ruby String methods > rather than direct manipulation. It would be short and fairly easy to > read. Well someone might want to give that a go. I tightened Pathname up "real good" using an Array --which works very nicely as far as overall design is concerned. For example: def +(other) other = Pathname.new(other) unless Pathname === other return other if other.absolute? pth = @path + other.pathlist # arrays pth.delete('.') Pathname.create(pth, @absolute, other.trail?) end But the speed only improved about 20%. I got my benchmark below a second, but that's still almost 5 times slower than File.join. Also I noticed that Pathname depends on File, Dir, FileUtils, FileTest and Find. While I'd imagine there be some dependency (especially to deal with cross-platform issues), this is much less self contained then I imagined it would be. T.