Tracerestrict: Avoid double lookup when setting is restricted map bit

This commit is contained in:
Jonathan G Rennison
2022-06-11 22:12:43 +01:00
parent ccfcc22c03
commit c06acd3c47

View File

@@ -1198,17 +1198,16 @@ void TraceRestrictSetIsSignalRestrictedBit(TileIndex t)
// First mapping for this tile, or later
TraceRestrictMapping::iterator lower_bound = _tracerestrictprogram_mapping.lower_bound(MakeTraceRestrictRefId(t, static_cast<Track>(0)));
// First mapping for next tile, or later
TraceRestrictMapping::iterator upper_bound = _tracerestrictprogram_mapping.lower_bound(MakeTraceRestrictRefId(t + 1, static_cast<Track>(0)));
bool found = (lower_bound != _tracerestrictprogram_mapping.end()) && (GetTraceRestrictRefIdTileIndex(lower_bound->first) == t);
// If iterators are the same, there are no mappings for this tile
switch (GetTileType(t)) {
case MP_RAILWAY:
SetRestrictedSignal(t, lower_bound != upper_bound);
SetRestrictedSignal(t, found);
break;
case MP_TUNNELBRIDGE:
SetTunnelBridgeRestrictedSignal(t, lower_bound != upper_bound);
SetTunnelBridgeRestrictedSignal(t, found);
break;
default: