From c06acd3c47c7747f41e1699c4dfb47cf0cc68aa9 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 11 Jun 2022 22:12:43 +0100 Subject: [PATCH] Tracerestrict: Avoid double lookup when setting is restricted map bit --- src/tracerestrict.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/tracerestrict.cpp b/src/tracerestrict.cpp index 0a80f456df..e7e0301a7a 100644 --- a/src/tracerestrict.cpp +++ b/src/tracerestrict.cpp @@ -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(0))); - // First mapping for next tile, or later - TraceRestrictMapping::iterator upper_bound = _tracerestrictprogram_mapping.lower_bound(MakeTraceRestrictRefId(t + 1, static_cast(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: