Skip to content

Commit bc45c9b

Browse files
committed
remove unnecessary temporary vector from GetTrackOrEnvelopeFromY
1 parent 168bbc2 commit bc45c9b

File tree

1 file changed

+11
-26
lines changed

1 file changed

+11
-26
lines changed

Breeder/BR_MouseUtil.cpp

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,45 +1476,30 @@ void BR_MouseInfo::GetTrackOrEnvelopeFromY (int y, TrackEnvelope** _envelope, Me
14761476
TrackEnvelope* envelope = NULL;
14771477
if (track)
14781478
{
1479+
const bool yInTrack = y < elementOffset + elementHeight;
1480+
const int count = CountTrackEnvelopes(track);
14791481
elementHeight = GetTrackHeightWithSpacer(track);
1480-
vector<pair<int,int>> envHeights;
1481-
bool yInTrack = (y < elementOffset + elementHeight) ? true : false;
14821482

1483-
int count = CountTrackEnvelopes(track);
14841483
for (int i = 0; i < count; ++i)
14851484
{
14861485
TrackEnvelope *env = GetTrackEnvelope(track, i);
1486+
const int envH = static_cast<int>(GetEnvelopeInfo_Value(env, "I_TCPH"));
1487+
if (envH < 1) continue;
14871488

1488-
if (GetEnvelopeInfo_Value(env,"I_TCPH") < 1.0) continue;
1489-
if (GetEnvelopeInfo_Value(env,"I_TCPY") < (elementHeight - spacer)) continue; // does not have an envcp
1489+
const int envY = static_cast<int>(GetEnvelopeInfo_Value(env, "I_TCPY"));
1490+
if (envY < elementHeight - spacer) continue; // does not have an envcp
14901491

14911492
if (yInTrack)
14921493
{
14931494
if (envelopes)
14941495
envelopes->push_back(env);
14951496
}
1496-
else
1497+
else if (y >= envY && y < envY + envH)
14971498
{
1498-
const int envHeight = static_cast<int>(GetEnvelopeInfo_Value(env,"I_TCPH"));
1499-
const int envId = i;
1500-
envHeights.push_back(make_pair(envHeight, envId));
1501-
}
1502-
}
1503-
1504-
if (!yInTrack)
1505-
{
1506-
int envelopeStart = elementOffset + elementHeight;
1507-
for (size_t i = 0; i < envHeights.size(); ++i)
1508-
{
1509-
int envelopeEnd = envelopeStart + envHeights[i].first;
1510-
if (y >= envelopeStart && y < envelopeEnd)
1511-
{
1512-
envelope = GetTrackEnvelope(track, envHeights[i].second);
1513-
elementHeight = envHeights[i].first;
1514-
elementOffset = envelopeStart;
1515-
break;
1516-
}
1517-
envelopeStart += envHeights[i].first;
1499+
envelope = env;
1500+
elementOffset = envY;
1501+
elementHeight = envH;
1502+
break;
15181503
}
15191504
}
15201505
}

0 commit comments

Comments
 (0)