From f491fa733b07b6016ac634e35579fb67b6eaad07 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Tue, 7 Feb 2006 18:55:06 +0000 Subject: (svn r3570) - Explicitly update v->first in TrainConsistChanged() if necessary, as this is far faster than brute forcing it later. --- train_cmd.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'train_cmd.c') diff --git a/train_cmd.c b/train_cmd.c index 045b7d478..309ddc128 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -93,6 +93,9 @@ void TrainConsistChanged(Vehicle* v) const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type); uint16 veh_len; + // Update the v->first cache. This is faster than having to brute force it later. + if (u->first == NULL) u->first = v; + // update the 'first engine' u->u.rail.first_engine = (v == u) ? INVALID_VEHICLE : first_engine; -- cgit v1.2.3-54-g00ecf