Delay writing image cache index while loading songs (#1917)
This commit is contained in:
+9
-1
@@ -169,6 +169,7 @@ void ImageCache::UnloadAllImages()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImageCache::ImageCache()
|
ImageCache::ImageCache()
|
||||||
|
: delay_save_cache(false)
|
||||||
{
|
{
|
||||||
ReadFromDisk();
|
ReadFromDisk();
|
||||||
}
|
}
|
||||||
@@ -457,9 +458,16 @@ void ImageCache::CacheImageInternal( RString sImageDir, RString sImagePath )
|
|||||||
ImageData.SetValue( sImagePath, "Width", iSourceWidth );
|
ImageData.SetValue( sImagePath, "Width", iSourceWidth );
|
||||||
ImageData.SetValue( sImagePath, "Height", iSourceHeight );
|
ImageData.SetValue( sImagePath, "Height", iSourceHeight );
|
||||||
ImageData.SetValue( sImagePath, "FullHash", GetHashForFile( sImagePath ) );
|
ImageData.SetValue( sImagePath, "FullHash", GetHashForFile( sImagePath ) );
|
||||||
ImageData.WriteFile( IMAGE_CACHE_INDEX );
|
if (!delay_save_cache)
|
||||||
|
WriteToDisk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImageCache::WriteToDisk()
|
||||||
|
{
|
||||||
|
ImageData.WriteFile(IMAGE_CACHE_INDEX);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2003 Glenn Maynard
|
* (c) 2003 Glenn Maynard
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public:
|
|||||||
ImageCache();
|
ImageCache();
|
||||||
~ImageCache();
|
~ImageCache();
|
||||||
void ReadFromDisk();
|
void ReadFromDisk();
|
||||||
|
void WriteToDisk();
|
||||||
|
|
||||||
RageTextureID LoadCachedImage( RString sImageDir, RString sImagePath );
|
RageTextureID LoadCachedImage( RString sImageDir, RString sImagePath );
|
||||||
void CacheImage( RString sImageDir, RString sImagePath );
|
void CacheImage( RString sImageDir, RString sImagePath );
|
||||||
@@ -23,6 +24,8 @@ public:
|
|||||||
|
|
||||||
void OutputStats() const;
|
void OutputStats() const;
|
||||||
|
|
||||||
|
bool delay_save_cache;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static RString GetImageCachePath( RString sImageDir, RString sImagePath );
|
static RString GetImageCachePath( RString sImageDir, RString sImagePath );
|
||||||
void UnloadAllImages();
|
void UnloadAllImages();
|
||||||
|
|||||||
+4
-1
@@ -158,7 +158,8 @@ void SongManager::InitSongsFromDisk( LoadingWindow *ld )
|
|||||||
RageTimer tm;
|
RageTimer tm;
|
||||||
// Tell SONGINDEX to not write the cache index file every time a song adds
|
// Tell SONGINDEX to not write the cache index file every time a song adds
|
||||||
// an entry. -Kyz
|
// an entry. -Kyz
|
||||||
SONGINDEX->delay_save_cache= true;
|
SONGINDEX->delay_save_cache = true;
|
||||||
|
IMAGECACHE->delay_save_cache = true;
|
||||||
LoadStepManiaSongDir( SpecialFiles::SONGS_DIR, ld );
|
LoadStepManiaSongDir( SpecialFiles::SONGS_DIR, ld );
|
||||||
|
|
||||||
const bool bOldVal = PREFSMAN->m_bFastLoad;
|
const bool bOldVal = PREFSMAN->m_bFastLoad;
|
||||||
@@ -168,6 +169,8 @@ void SongManager::InitSongsFromDisk( LoadingWindow *ld )
|
|||||||
LoadEnabledSongsFromPref();
|
LoadEnabledSongsFromPref();
|
||||||
SONGINDEX->SaveCacheIndex();
|
SONGINDEX->SaveCacheIndex();
|
||||||
SONGINDEX->delay_save_cache= false;
|
SONGINDEX->delay_save_cache= false;
|
||||||
|
IMAGECACHE->WriteToDisk();
|
||||||
|
IMAGECACHE->delay_save_cache = false;
|
||||||
|
|
||||||
LOG->Trace( "Found %d songs in %f seconds.", (int)m_pSongs.size(), tm.GetDeltaTime() );
|
LOG->Trace( "Found %d songs in %f seconds.", (int)m_pSongs.size(), tm.GetDeltaTime() );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user