mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-30 20:11:23 +00:00
Reduce critical sections size
This commit is contained in:
parent
a5b078e9a7
commit
563f3f87dd
2 changed files with 5 additions and 3 deletions
|
@ -38,8 +38,9 @@ namespace DetourNavigator
|
||||||
return false;
|
return false;
|
||||||
std::vector<TilePosition> tilesPositions;
|
std::vector<TilePosition> tilesPositions;
|
||||||
{
|
{
|
||||||
|
const TilesPositionsRange range = makeTilesPositionsRange(shape.getShape(), transform, mSettings);
|
||||||
const std::lock_guard lock(mMutex);
|
const std::lock_guard lock(mMutex);
|
||||||
getTilesPositions(makeTilesPositionsRange(shape.getShape(), transform, mSettings),
|
getTilesPositions(range,
|
||||||
[&] (const TilePosition& tilePosition)
|
[&] (const TilePosition& tilePosition)
|
||||||
{
|
{
|
||||||
if (addTile(id, shape, transform, areaType, tilePosition, mTiles))
|
if (addTile(id, shape, transform, areaType, tilePosition, mTiles))
|
||||||
|
|
|
@ -38,7 +38,6 @@ namespace DetourNavigator
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
std::vector<TilePosition> newTiles;
|
std::vector<TilePosition> newTiles;
|
||||||
{
|
{
|
||||||
const std::lock_guard lock(mMutex);
|
|
||||||
const auto onTilePosition = [&] (const TilePosition& tilePosition)
|
const auto onTilePosition = [&] (const TilePosition& tilePosition)
|
||||||
{
|
{
|
||||||
if (std::binary_search(currentTiles.begin(), currentTiles.end(), tilePosition))
|
if (std::binary_search(currentTiles.begin(), currentTiles.end(), tilePosition))
|
||||||
|
@ -57,7 +56,9 @@ namespace DetourNavigator
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
getTilesPositions(makeTilesPositionsRange(shape.getShape(), transform, mSettings), onTilePosition);
|
const TilesPositionsRange range = makeTilesPositionsRange(shape.getShape(), transform, mSettings);
|
||||||
|
const std::lock_guard lock(mMutex);
|
||||||
|
getTilesPositions(range, onTilePosition);
|
||||||
std::sort(newTiles.begin(), newTiles.end());
|
std::sort(newTiles.begin(), newTiles.end());
|
||||||
for (const auto& tile : currentTiles)
|
for (const auto& tile : currentTiles)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue