TapNotes are not huge structures but there are generally a lot of them and they do contain at least one nontrivial ctor so avoid making copies of them when possible.

This commit is contained in:
Steve Checkoway
2006-07-24 04:42:08 +00:00
parent 1ca8ec0f11
commit 20b45c5243
+7 -9
View File
@@ -1093,7 +1093,7 @@ void Player::HandleStep( int col, const RageTimer &tm, bool bHeld )
const float fSecondsFromExact = fabsf( fNoteOffset ); const float fSecondsFromExact = fabsf( fNoteOffset );
TapNote tn = m_NoteData.GetTapNote( col, iIndexOverlappingNote ); TapNote &tn = m_NoteData.FindTapNote( col, iIndexOverlappingNote )->second;
switch( m_pPlayerState->m_PlayerController ) switch( m_pPlayerState->m_PlayerController )
{ {
@@ -1224,8 +1224,6 @@ void Player::HandleStep( int col, const RageTimer &tm, bool bHeld )
if( score != TNS_None ) if( score != TNS_None )
tn.result.fTapNoteOffset = -fNoteOffset; tn.result.fTapNoteOffset = -fNoteOffset;
m_NoteData.SetTapNote( col, iIndexOverlappingNote, tn );
PlayerNumber pn = tn.pn == PLAYER_INVALID ? m_pPlayerState->m_PlayerNumber : tn.pn; PlayerNumber pn = tn.pn == PLAYER_INVALID ? m_pPlayerState->m_PlayerNumber : tn.pn;
m_LastTapNoteScore = score; m_LastTapNoteScore = score;
if( GAMESTATE->GetCurrentGame()->m_bCountNotesSeparately ) if( GAMESTATE->GetCurrentGame()->m_bCountNotesSeparately )
@@ -1509,20 +1507,20 @@ void Player::RandomizeNotes( int iNoteRow )
const int iSwapWith = RandomInt( iNumOfTracks ); const int iSwapWith = RandomInt( iNumOfTracks );
/* Only swap a tap and an empty. */ /* Only swap a tap and an empty. */
const TapNote t1 = m_NoteData.GetTapNote( t, iNewNoteRow ); NoteData::iterator iter = m_NoteData.FindTapNote( t, iNewNoteRow );
if( t1.type != TapNote::tap ) if( iter == m_NoteData.end(t) || iter->second.type != TapNote::tap )
continue; continue;
const TapNote t2 = m_NoteData.GetTapNote( iSwapWith, iNewNoteRow ); // Make sure this is empty.
if( t2.type != TapNote::empty ) if( m_NoteData.FindTapNote(iSwapWith, iNewNoteRow) != m_NoteData.end(iSwapWith) )
continue; continue;
/* Make sure the destination row isn't in the middle of a hold. */ /* Make sure the destination row isn't in the middle of a hold. */
if( m_NoteData.IsHoldNoteAtRow(iSwapWith, iNoteRow) ) if( m_NoteData.IsHoldNoteAtRow(iSwapWith, iNoteRow) )
continue; continue;
m_NoteData.SetTapNote( t, iNewNoteRow, t2 ); m_NoteData.SetTapNote( iSwapWith, iNewNoteRow, iter->second );
m_NoteData.SetTapNote( iSwapWith, iNewNoteRow, t1 ); m_NoteData.RemoveTapNote( t, iter );
} }
} }