Improve performance of name sorting in town and station list windows
This commit is contained in:
@@ -456,6 +456,26 @@ void UpdateAllStationVirtCoords()
|
||||
}
|
||||
}
|
||||
|
||||
void BaseStation::FillCachedName()
|
||||
{
|
||||
char buf[256];
|
||||
int64 args_array[] = { this->index };
|
||||
StringParameters tmp_params(args_array);
|
||||
char *end = GetStringWithArgs(buf, Waypoint::IsExpected(this) ? STR_WAYPOINT_NAME : STR_STATION_NAME, &tmp_params, lastof(buf));
|
||||
char *alloced = MallocT<char>(end - buf + 1);
|
||||
memcpy(alloced, buf, end - buf + 1);
|
||||
this->cached_name.reset(alloced);
|
||||
}
|
||||
|
||||
void ClearAllStationCachedNames()
|
||||
{
|
||||
BaseStation *st;
|
||||
|
||||
FOR_ALL_BASE_STATIONS(st) {
|
||||
st->cached_name.reset();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a mask of the cargo types that the station accepts.
|
||||
* @param st Station to query
|
||||
@@ -4006,6 +4026,7 @@ CommandCost CmdRenameStation(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
st->cached_name.reset();
|
||||
free(st->name);
|
||||
st->name = reset ? nullptr : stredup(text);
|
||||
|
||||
|
Reference in New Issue
Block a user