Best fix for 87864, prevent duplicate bookmarks from being processed when loading a bookmarks file.

This code was originally removed from 6.1 because performance issues with IndexOf, which have recently been addressed. r=pchen, sr=waterson
This commit is contained in:
ben%netscape.com 2001-10-20 09:26:40 +00:00
Родитель ccf920d8ed
Коммит 41f3c95e4b
1 изменённых файлов: 12 добавлений и 4 удалений

Просмотреть файл

@ -1217,10 +1217,18 @@ BookmarkParser::ParseBookmarkInfo(BookmarkField *fields, PRBool isBookmarkFlag,
}
}
// The last thing we do is add the bookmark to the container.
// This ensures the minimal amount of reflow.
rv = aContainer->AppendElement(bookmark);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to add bookmark to container");
// prevent duplicates
PRInt32 aIndex;
nsCOMPtr<nsIRDFResource> containerRes;
aContainer->GetResource(getter_AddRefs(containerRes));
if (containerRes && NS_SUCCEEDED(gRDFC->IndexOf(mDataSource, containerRes, bookmark, &aIndex)) &&
(aIndex < 0))
{
// The last thing we do is add the bookmark to the container.
// This ensures the minimal amount of reflow.
rv = aContainer->AppendElement(bookmark);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to add bookmark to container");
}
}
// free up any allocated data in field table AFTER processing