mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Replaced SmallVector::ErasePreservingOrder(it, count) with std::vector::erase()
parent
8460952240
commit
9b5cc73f3e
|
@ -27,10 +27,10 @@ SmallVector<TileIndex, 256> _animated_tiles;
|
||||||
*/
|
*/
|
||||||
void DeleteAnimatedTile(TileIndex tile)
|
void DeleteAnimatedTile(TileIndex tile)
|
||||||
{
|
{
|
||||||
TileIndex *to_remove = &*std::find(_animated_tiles.begin(), _animated_tiles.end(), tile);
|
auto to_remove = std::find(_animated_tiles.begin(), _animated_tiles.end(), tile);
|
||||||
if (to_remove != _animated_tiles.End()) {
|
if (to_remove != _animated_tiles.end()) {
|
||||||
/* The order of the remaining elements must stay the same, otherwise the animation loop may miss a tile. */
|
/* The order of the remaining elements must stay the same, otherwise the animation loop may miss a tile. */
|
||||||
_animated_tiles.ErasePreservingOrder(to_remove);
|
_animated_tiles.erase(to_remove);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,16 +148,6 @@ public:
|
||||||
std::vector<T>::erase(it, it + count);
|
std::vector<T>::erase(it, it + count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove items from the vector while preserving the order of other items.
|
|
||||||
* @param item First item to remove.
|
|
||||||
* @param count Number of consecutive items to remove.
|
|
||||||
*/
|
|
||||||
inline void ErasePreservingOrder(T *item, uint count = 1)
|
|
||||||
{
|
|
||||||
this->ErasePreservingOrder(item - this->Begin(), count);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether a item is present in the vector, and appends it to the end if not.
|
* Tests whether a item is present in the vector, and appends it to the end if not.
|
||||||
* The '!=' operator of T is used for comparison.
|
* The '!=' operator of T is used for comparison.
|
||||||
|
|
Loading…
Reference in New Issue