diff options
author | Jonathan G Rennison <j.g.rennison@gmail.com> | 2021-02-27 19:24:22 +0000 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-03-10 23:28:10 +0100 |
commit | c0b722ec46f13c04125fb122692aa975abe4f8d9 (patch) | |
tree | 490344ed706493843ea09172424de297629fb453 /src | |
parent | 1fb1e7503880a052a43f0ef819f718718976ab77 (diff) | |
download | openttd-c0b722ec46f13c04125fb122692aa975abe4f8d9.tar.xz |
Codechange: Add fast path to catenary drawing in MaskWireBits
MaskWireBits always returns its input unchanged if the input
has only 0 or 1 track bits set.
Having only 0 or 1 track bits sets (i.e. non junction tiles)
is by far the most common case.
Examining the state of neighbouring tiles and the subsequent
masking logic is relatively expensive and can be omitted in this case.
Diffstat (limited to 'src')
-rw-r--r-- | src/elrail.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/elrail.cpp b/src/elrail.cpp index 5d8f2b8f3..44481dd31 100644 --- a/src/elrail.cpp +++ b/src/elrail.cpp @@ -124,6 +124,9 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override) */ static TrackBits MaskWireBits(TileIndex t, TrackBits tracks) { + /* Single track bits are never masked out. */ + if (likely(HasAtMostOneBit(tracks))) return tracks; + if (!IsPlainRailTile(t)) return tracks; TrackdirBits neighbour_tdb = TRACKDIR_BIT_NONE; |