KSycocaFactory question
Thomas Braxton
brax108 at cox.net
Wed Dec 7 07:02:27 GMT 2005
In kdecore/ksycocafactory.cpp:181 we have:
qint32 *offsetList = new qint32[entryCount];
for(int i = 0; i < entryCount; i++)
{
stream >> offsetList[i];
}
for(int i = 0; i < entryCount; i++)
{
KSycocaEntry *newEntry = createEntry(offsetList[i]);
if (newEntry)
{
list.append( KSycocaEntry::Ptr( newEntry ) );
}
}
delete [] offsetList;
couldn't this be changed to:
qint32 offset;
for(int i = 0; i < entryCount; i++)
{
stream >> offset;
KSycocaEntry *newEntry = createEntry(offset);
if (newEntry)
{
list.append( KSycocaEntry::Ptr( newEntry ) );
}
}
It doesn't seem to be usefull to allocate offsetList just to delete it right
away. Why not just get rid of the wasteful allocation and deletion. There
also doesn't seem to be a reason to iterate through two loops when one can
clearly suffice. This code seems to also be copy/pasted to
kio/kio/kservicefactory.cpp
Is it OK if I change these to the second form or am I missing something?
More information about the kde-core-devel
mailing list