Tracerestrict: Avoid double lookup when setting is restricted map bit
This commit is contained in:
@@ -1198,17 +1198,16 @@ void TraceRestrictSetIsSignalRestrictedBit(TileIndex t)
|
|||||||
// First mapping for this tile, or later
|
// First mapping for this tile, or later
|
||||||
TraceRestrictMapping::iterator lower_bound = _tracerestrictprogram_mapping.lower_bound(MakeTraceRestrictRefId(t, static_cast<Track>(0)));
|
TraceRestrictMapping::iterator lower_bound = _tracerestrictprogram_mapping.lower_bound(MakeTraceRestrictRefId(t, static_cast<Track>(0)));
|
||||||
|
|
||||||
// First mapping for next tile, or later
|
bool found = (lower_bound != _tracerestrictprogram_mapping.end()) && (GetTraceRestrictRefIdTileIndex(lower_bound->first) == t);
|
||||||
TraceRestrictMapping::iterator upper_bound = _tracerestrictprogram_mapping.lower_bound(MakeTraceRestrictRefId(t + 1, static_cast<Track>(0)));
|
|
||||||
|
|
||||||
// If iterators are the same, there are no mappings for this tile
|
// If iterators are the same, there are no mappings for this tile
|
||||||
switch (GetTileType(t)) {
|
switch (GetTileType(t)) {
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
SetRestrictedSignal(t, lower_bound != upper_bound);
|
SetRestrictedSignal(t, found);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_TUNNELBRIDGE:
|
case MP_TUNNELBRIDGE:
|
||||||
SetTunnelBridgeRestrictedSignal(t, lower_bound != upper_bound);
|
SetTunnelBridgeRestrictedSignal(t, found);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Reference in New Issue
Block a user