Skip to content

Commit

Permalink
Font Renderer|Client: Font id=0 is never used so don't search
Browse files Browse the repository at this point in the history
Evidently the game HUD drawer repeatedly attempts to set the current
font with id #0, resulting in a performance issue due to exception
throwing as a result.

In this special case we can simply avoid searching.
  • Loading branch information
danij-deng committed Nov 15, 2013
1 parent 7597bce commit 2740cbb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
25 changes: 14 additions & 11 deletions doomsday/client/src/render/rend_font.cpp
Expand Up @@ -162,15 +162,22 @@ void FR_ResetTypeinTimer(void)
void FR_SetFont(fontid_t num)
{
errorIfNotInited("FR_SetFont");
try
if(num != NOFONTID)
{
try
{
App_Fonts().toManifest(num);
fr.fontNum = num;
return;
}
catch(Fonts::UnknownIdError const &)
{}
//LogBuffer_Printf(DE2_LOG_WARNING, "Requested invalid font %i.\n", num);
}
else
{
App_Fonts().toManifest(num);
fr.fontNum = num;
return;
}
catch(Fonts::UnknownIdError const &)
{}
//LogBuffer_Printf(DE2_LOG_WARNING, "Requested invalid font %i.\n", num);
}

void FR_SetNoFont(void)
Expand Down Expand Up @@ -1543,11 +1550,7 @@ DENG_EXTERN_C fontid_t Fonts_ResolveUri(uri_s const *uri)
if(!uri) return NOFONTID;
try
{
FontManifest &manifest = App_Fonts().find(*reinterpret_cast<de::Uri const *>(uri));
if(manifest.hasFont())
{
return manifest.uniqueId();
}
return App_Fonts().find(*reinterpret_cast<de::Uri const *>(uri)).uniqueId();
}
catch(Fonts::NotFoundError const &)
{}
Expand Down
5 changes: 3 additions & 2 deletions doomsday/client/src/resource/resourcesystem.cpp
Expand Up @@ -1053,13 +1053,14 @@ AbstractFont *ResourceSystem::createFontFromFile(de::Uri const &uri,

if(!App_FileSystem().accessFile(de::Uri::fromNativePath(filePath)))
{
LOG_WARNING("Invalid resourcePath reference, ignoring.");
LOG_WARNING("Invalid filePath, ignoring.");
return 0;
}

try
{
FontManifest &manifest = d->fonts.scheme(uri.scheme()).declare(uri.path());
// Create/retrieve a manifest for the would-be font.
FontManifest &manifest = d->fonts.declare(uri);

if(manifest.hasFont())
{
Expand Down

0 comments on commit 2740cbb

Please sign in to comment.