Don't compute the compressed string or the hash unless it is required.
This commit is contained in:
+19
-3
@@ -45,6 +45,22 @@ Steps::~Steps()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned Steps::GetHash() const
|
||||||
|
{
|
||||||
|
if( parent )
|
||||||
|
return parent->GetHash();
|
||||||
|
if( m_uHash )
|
||||||
|
return m_uHash;
|
||||||
|
if( m_sNoteDataCompressed.empty() )
|
||||||
|
{
|
||||||
|
if( !m_bNoteDataIsFilled )
|
||||||
|
return 0; // No data, no hash.
|
||||||
|
NoteDataUtil::GetSMNoteDataString( *m_pNoteData, m_sNoteDataCompressed );
|
||||||
|
}
|
||||||
|
m_uHash = GetHashForString( m_sNoteDataCompressed );
|
||||||
|
return m_uHash;
|
||||||
|
}
|
||||||
|
|
||||||
void Steps::SetNoteData( const NoteData& noteDataNew )
|
void Steps::SetNoteData( const NoteData& noteDataNew )
|
||||||
{
|
{
|
||||||
ASSERT( noteDataNew.GetNumTracks() == GameManager::StepsTypeToNumTracks(m_StepsType) );
|
ASSERT( noteDataNew.GetNumTracks() == GameManager::StepsTypeToNumTracks(m_StepsType) );
|
||||||
@@ -61,8 +77,8 @@ void Steps::SetNoteData( const NoteData& noteDataNew )
|
|||||||
*m_pNoteData = noteDataNew;
|
*m_pNoteData = noteDataNew;
|
||||||
m_bNoteDataIsFilled = true;
|
m_bNoteDataIsFilled = true;
|
||||||
|
|
||||||
NoteDataUtil::GetSMNoteDataString( *m_pNoteData, m_sNoteDataCompressed );
|
m_sNoteDataCompressed = EMPTY_STRING;
|
||||||
m_uHash = GetHashForString( m_sNoteDataCompressed );
|
m_uHash = 0;
|
||||||
m_sFilename = EMPTY_STRING; // We can no longer read from the file because it has changed in memory.
|
m_sFilename = EMPTY_STRING; // We can no longer read from the file because it has changed in memory.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +103,7 @@ void Steps::SetSMNoteData( const RString ¬es_comp_ )
|
|||||||
m_bNoteDataIsFilled = false;
|
m_bNoteDataIsFilled = false;
|
||||||
|
|
||||||
m_sNoteDataCompressed = notes_comp_;
|
m_sNoteDataCompressed = notes_comp_;
|
||||||
m_uHash = GetHashForString( m_sNoteDataCompressed );
|
m_uHash = 0;
|
||||||
m_sFilename = EMPTY_STRING; // We can no longer read from the file because it has changed in memory.
|
m_sFilename = EMPTY_STRING; // We can no longer read from the file because it has changed in memory.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ public:
|
|||||||
bool IsAPlayerEdit() const { return IsAnEdit() && GetLoadedFromProfileSlot() < ProfileSlot_Machine; }
|
bool IsAPlayerEdit() const { return IsAnEdit() && GetLoadedFromProfileSlot() < ProfileSlot_Machine; }
|
||||||
bool WasLoadedFromProfile() const { return m_LoadedFromProfile != ProfileSlot_INVALID; }
|
bool WasLoadedFromProfile() const { return m_LoadedFromProfile != ProfileSlot_INVALID; }
|
||||||
ProfileSlot GetLoadedFromProfileSlot() const { return m_LoadedFromProfile; }
|
ProfileSlot GetLoadedFromProfileSlot() const { return m_LoadedFromProfile; }
|
||||||
unsigned GetHash() const { return Real()->m_uHash; }
|
|
||||||
RString GetDescription() const { return Real()->m_sDescription; }
|
RString GetDescription() const { return Real()->m_sDescription; }
|
||||||
Difficulty GetDifficulty() const { return Real()->m_Difficulty; }
|
Difficulty GetDifficulty() const { return Real()->m_Difficulty; }
|
||||||
int GetMeter() const { return Real()->m_iMeter; }
|
int GetMeter() const { return Real()->m_iMeter; }
|
||||||
@@ -56,6 +55,7 @@ public:
|
|||||||
void SetCachedRadarValues( const RadarValues v[NUM_PLAYERS] );
|
void SetCachedRadarValues( const RadarValues v[NUM_PLAYERS] );
|
||||||
float PredictMeter() const;
|
float PredictMeter() const;
|
||||||
|
|
||||||
|
unsigned GetHash() const;
|
||||||
void GetNoteData( NoteData& noteDataOut ) const;
|
void GetNoteData( NoteData& noteDataOut ) const;
|
||||||
void SetNoteData( const NoteData& noteDataNew );
|
void SetNoteData( const NoteData& noteDataNew );
|
||||||
void SetSMNoteData( const RString ¬es_comp );
|
void SetSMNoteData( const RString ¬es_comp );
|
||||||
@@ -87,7 +87,7 @@ private:
|
|||||||
ProfileSlot m_LoadedFromProfile; // ProfileSlot_INVALID if wasn't loaded from a profile
|
ProfileSlot m_LoadedFromProfile; // ProfileSlot_INVALID if wasn't loaded from a profile
|
||||||
|
|
||||||
/* These values are pulled from the autogen source first, if there is one. */
|
/* These values are pulled from the autogen source first, if there is one. */
|
||||||
unsigned m_uHash; // only used if m_Difficulty == DIFFICULTY_EDIT
|
mutable unsigned m_uHash; // only used if m_Difficulty == DIFFICULTY_EDIT
|
||||||
RString m_sDescription; // Step author, edit name, or something meaningful
|
RString m_sDescription; // Step author, edit name, or something meaningful
|
||||||
Difficulty m_Difficulty; // difficulty classification
|
Difficulty m_Difficulty; // difficulty classification
|
||||||
int m_iMeter; // difficulty rating from MIN_METER to MAX_METER
|
int m_iMeter; // difficulty rating from MIN_METER to MAX_METER
|
||||||
|
|||||||
Reference in New Issue
Block a user