[PATCH] New KFileItem::assign() for Optimizing KDirListerCache

David Faure faure at kde.org
Fri Mar 25 14:57:05 GMT 2005


On Friday 25 March 2005 15:41, Michael Brade wrote:
> On Friday 25 March 2005 15:27, David Faure wrote:
> > > But I don't use it to update the item (which can also be confused with
> > > refresh) but rather to make it an entirely new item... The method is a
> > > shortcut for 'delete item; item = new KFileItem( udsEntry ... );'.
> >
> > This sounds a bit weird :)
> > I mean, for any other class you wouldn't have a method for doing that, you
> > would just do *item = KFileItem( udsEntry... );
> > No new/delete there, only an instance created on the stack, and a call to
> > the assignment operator.
> Well yes, but I think that would still be slower than "updating" the item 
> in-place, no? With the new setUDSEntry not even the instance on the stack is 
> needed, no CTOR call at all.

Hmm, basically all you gain is a call to assign, which isn't much, but OK.
(the ctor call does the same job as setUDSEntry anyway)

Similary we don't have KURL::setURL(), one has to use u = KURL( newString [,options] )
which also needs a ctor call and an assignment, but maybe you're right that we should
have that, if used in loops.

OTOH I just noticed that the patch removes this from refresh() - why?
-  m_access = QString::null;
-  m_size = (KIO::filesize_t) -1;
   m_metaInfo = KFileMetaInfo();
-  for ( int i = 0; i < NumFlags; i++ )
-      m_time[i] = (time_t) -1;
IIRC this is needed when the permissions, size, or access times of a file have changed.

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list