1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-29 22:20:33 +00:00

Reduce critical sections size

This commit is contained in:
elsid 2022-02-01 00:42:03 +01:00
parent a5b078e9a7
commit 563f3f87dd
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40
2 changed files with 5 additions and 3 deletions

View File

@ -38,8 +38,9 @@ namespace DetourNavigator
return false;
std::vector<TilePosition> tilesPositions;
{
const TilesPositionsRange range = makeTilesPositionsRange(shape.getShape(), transform, mSettings);
const std::lock_guard lock(mMutex);
getTilesPositions(makeTilesPositionsRange(shape.getShape(), transform, mSettings),
getTilesPositions(range,
[&] (const TilePosition& tilePosition)
{
if (addTile(id, shape, transform, areaType, tilePosition, mTiles))

View File

@ -38,7 +38,6 @@ namespace DetourNavigator
bool changed = false;
std::vector<TilePosition> newTiles;
{
const std::lock_guard lock(mMutex);
const auto onTilePosition = [&] (const TilePosition& tilePosition)
{
if (std::binary_search(currentTiles.begin(), currentTiles.end(), tilePosition))
@ -57,7 +56,9 @@ namespace DetourNavigator
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());
for (const auto& tile : currentTiles)
{