Vincent van Ravesteijn wrote: > For the statistics: > > With 2 graphics, there are 60 calls to FileName::==(), > With 20 graphics, there are 570 calls to FileName::==(), > With 60, graphics, there are 1760 calls to FileName::==(), which is at > least 10560 file accesses... > > When deleting the 60 graphics, the count stops at 2160 times > FileName::==().. i.e. lunch break. > > Georg's patch solves this, as the ==() operator isn't so expensive most > of the times.., but again, it makes no sense to compare that many > filenames to each other...
As I wrote earlier: A lot of code assumes that FileName is cheap. Would you count the calls to string::operator==()? Probably not. > Please tell me why this is absolutely needed ;-).. I am sure that you can optimize several calls away. IMHO, there are basically two options: 1) Restore the original semantics of the FileName class as a cheap wrapper around a string, that does not do any file system access unless explicitly requested. My patch is a start. 2) Keep the current semantics of the FileName class as a general file info utility. That would imply renaming it into e.g. FileInfo. Then the code could be audited to use this class more efficiently. If you chose option 2) please do not keep the FileName name, because it does not describe at all what this class does. Georg