Permalink
Browse files

Optimized a bit more the glyph cache parsing.

From 4144 advice
  • Loading branch information...
1 parent 9de4c3e commit a56bf2fb257a341a9bce0933af723f8218c7dc13 Yohann Ferreira committed Sep 23, 2012
Showing with 12 additions and 9 deletions.
  1. +2 −1 src/engine/video/text.cpp
  2. +10 −8 src/engine/video/texture_controller.cpp
@@ -517,7 +517,8 @@ TextSupervisor::~TextSupervisor() {
TTF_CloseFont(fp->ttf_font);
if (fp->glyph_cache) {
- for (std::vector<FontGlyph*>::iterator j = fp->glyph_cache->begin(); j != fp->glyph_cache->end(); ++j) {
+ std::vector<hoa_video::FontGlyph*>::iterator it_end = fp->glyph_cache->end();
+ for (std::vector<FontGlyph*>::iterator j = fp->glyph_cache->begin(); j != it_end; ++j) {
delete *j;
}
delete fp->glyph_cache;
@@ -113,21 +113,23 @@ bool TextureController::UnloadTextures() {
// Clear all font caches
std::map<std::string, FontProperties*>::iterator j = TextManager->_font_map.begin();
- while (j != TextManager->_font_map.end()) {
- FontProperties *fp = j->second;
-
- if (fp->glyph_cache) {
- for (std::vector<FontGlyph*>::iterator k = fp->glyph_cache->begin();
- k != fp->glyph_cache->end(); ++k) {
+ std::map<std::string, FontProperties*>::iterator j_end = TextManager->_font_map.end();
+ while (j != j_end) {
+ std::vector<FontGlyph*>* glyph_cache = j->second->glyph_cache;
+
+ if (glyph_cache) {
+ std::vector<hoa_video::FontGlyph*>::iterator it_end = glyph_cache->end();
+ for (std::vector<FontGlyph*>::iterator k = glyph_cache->begin();
+ k != it_end; ++k) {
if (*k)
_DeleteTexture((*k)->texture);
delete *k;
}
- fp->glyph_cache->clear();
+ glyph_cache->clear();
}
- j++;
+ ++j;
}
return success;

0 comments on commit a56bf2f

Please sign in to comment.