SimpleFontData* FontCache::getCachedFontData(const FontPlatformData* platformData) { if (!platformData) return 0; if (!gFontDataCache) { gFontDataCache = new FontDataCache; gInactiveFontData = new InactiveFontDataHashSet; } FontDataCache::iterator result = gFontDataCache->find(*platformData); if (result == gFontDataCache->end()) { if (gInactiveFontData->size() > cMaxInactiveFontData) purgeInactiveFontData((int)(cMaxInactiveFontData * cInactiveFontDataPurgeRatio)); pair<SimpleFontData*, unsigned> newValue(new SimpleFontData(*platformData), 1); // 6/15/09 CSidhall -Moved the add ref into the constructor of SimpleFontData gFontDataCache->set(*platformData, newValue); return newValue.first; } if (!result.get()->second.second++) { if(gInactiveFontData->contains(result.get()->second.first)) gInactiveFontData->remove(result.get()->second.first); } return result.get()->second.first; }
SimpleFontData* FontCache::getCachedFontData(const FontPlatformData* platformData) { if (!platformData) return 0; if (!gFontDataCache) { gFontDataCache = new FontDataCache; gInactiveFontData = new ListHashSet<const SimpleFontData*>; } FontDataCache::iterator result = gFontDataCache->find(*platformData); if (result == gFontDataCache->end()) { pair<SimpleFontData*, unsigned> newValue(new SimpleFontData(*platformData), 1); gFontDataCache->set(*platformData, newValue); return newValue.first; } if (!result.get()->second.second++) { ASSERT(gInactiveFontData->contains(result.get()->second.first)); gInactiveFontData->remove(result.get()->second.first); } return result.get()->second.first; }