Bug 1124973 (part 5) - Use PL_DHashTableSearch() in gfxFT2FontList.cpp. r=froydnj,jkew.
Because PL_DHashTableLookup() never returns null, GetInfoForFile() features not
one but *two* can-never-fail null checks on its result.
Having said that, the code as written works, at least for non-zero-sized files,
because |entry->mFileSize| will always be zero if the lookup fails (thanks to
PLDHashTable always being zeroed at construction, and |mMap| using
PL_DHashClearEntryStub which also zeroes).
But for zero-sized files the current code will act like they don't exist. Maybe
this can't happen in practice, but it seems dangerous and so I've changed it so
the new code will treat zero-sized files just like non-zero-sized files.
--- a/gfx/thebes/gfxFT2FontList.cpp
+++ b/gfx/thebes/gfxFT2FontList.cpp
@@ -710,23 +710,20 @@ public:
virtual void
GetInfoForFile(const nsCString& aFileName, nsCString& aFaceList,
uint32_t *aTimestamp, uint32_t *aFilesize)
{
if (!mMap.IsInitialized()) {
return;
}
- PLDHashEntryHdr *hdr =
- PL_DHashTableLookup(&mMap, aFileName.get());
- if (!hdr) {
- return;
- }
- FNCMapEntry* entry = static_cast<FNCMapEntry*>(hdr);
- if (entry && entry->mFilesize) {
+ FNCMapEntry *entry =
+ static_cast<FNCMapEntry*>(PL_DHashTableSearch(&mMap,
+ aFileName.get()));
+ if (entry) {
*aTimestamp = entry->mTimestamp;
*aFilesize = entry->mFilesize;
aFaceList.Assign(entry->mFaces);
// this entry does correspond to an existing file
// (although it might not be up-to-date, in which case
// it will get overwritten via CacheFileInfo)
entry->mFileExists = true;
}