Skip to content

Commit

Permalink
Added further noexcept specifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
javagl committed Sep 15, 2021
1 parent 588c5a1 commit a84b09c
Show file tree
Hide file tree
Showing 25 changed files with 105 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Tile;
class ITileExcluder {
public:
virtual ~ITileExcluder() = default;
virtual bool shouldExclude(const Tile& tile) const = 0;
virtual bool shouldExclude(const Tile& tile) const noexcept = 0;
};

} // namespace Cesium3DTilesSelection
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ class CESIUM3DTILESSELECTION_API RasterOverlayTileProvider {
* @param tile The tile that is starting to load.
* @param isThrottledLoad True if the load was originally throttled.
*/
void beginTileLoad(RasterOverlayTile& tile, bool isThrottledLoad);
void beginTileLoad(RasterOverlayTile& tile, bool isThrottledLoad) noexcept;

/**
* @brief Finalizes loading of a tile.
Expand All @@ -365,7 +365,7 @@ class CESIUM3DTILESSELECTION_API RasterOverlayTileProvider {
* @param tile The tile that finished loading.
* @param isThrottledLoad True if the load was originally throttled.
*/
void finalizeTileLoad(RasterOverlayTile& tile, bool isThrottledLoad);
void finalizeTileLoad(RasterOverlayTile& tile, bool isThrottledLoad) noexcept;

private:
RasterOverlay* _pOwner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CESIUM3DTILESSELECTION_API RasterizedPolygonsOverlay final
RasterOverlay* pOwner) override;

const std::vector<CesiumGeospatial::CartographicPolygon>&
getPolygons() const {
getPolygons() const noexcept {
return this->_polygons;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CESIUM3DTILESSELECTION_API RasterizedPolygonsTileExcluder
* @return true if the tile should be excluded because it is entirely inside a
* polygon.
*/
virtual bool shouldExclude(const Tile& tile) const override;
virtual bool shouldExclude(const Tile& tile) const noexcept override;

/**
* @brief Gets the overlay defining the polygons.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,11 @@ class CESIUM3DTILESSELECTION_API Tileset final {
const std::vector<ViewState>& frustums,
const Tile& tile,
const std::vector<double>& distances,
bool culled) const;
bool culled) const noexcept;

void _processLoadQueue();
void _unloadCachedTiles();
void _markTileVisited(Tile& tile);
void _unloadCachedTiles() noexcept;
void _markTileVisited(Tile& tile) noexcept;

std::string getResolvedContentUrl(const Tile& tile) const;

Expand Down
14 changes: 8 additions & 6 deletions Cesium3DTilesSelection/src/QuantizedMeshContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ struct QuantizedMeshView {
const size_t headerLength = 92;
const size_t extensionHeaderLength = 5;

int32_t zigZagDecode(int32_t value) { return (value >> 1) ^ (-(value & 1)); }
int32_t zigZagDecode(int32_t value) noexcept {
return (value >> 1) ^ (-(value & 1));
}

template <class E, class D>
void decodeIndices(const gsl::span<const E>& encoded, gsl::span<D>& decoded) {
Expand All @@ -139,7 +141,7 @@ template <class T>
static T readValue(
const gsl::span<const std::byte>& data,
size_t offset,
T defaultValue) {
T defaultValue) noexcept {
if (offset + sizeof(T) <= data.size()) {
return *reinterpret_cast<const T*>(data.data() + offset);
}
Expand Down Expand Up @@ -494,7 +496,7 @@ static void addSkirts(
westEdgeIndices.end(),
sortEdgeIndices.begin(),
sortEdgeIndices.begin() + westVertexCount,
[&uvsAndHeights](auto lhs, auto rhs) {
[&uvsAndHeights](auto lhs, auto rhs) noexcept {
return uvsAndHeights[lhs].y < uvsAndHeights[rhs].y;
});
westEdgeIndices = gsl::span(sortEdgeIndices.data(), westVertexCount);
Expand Down Expand Up @@ -525,7 +527,7 @@ static void addSkirts(
southEdgeIndices.end(),
sortEdgeIndices.begin(),
sortEdgeIndices.begin() + southVertexCount,
[&uvsAndHeights](auto lhs, auto rhs) {
[&uvsAndHeights](auto lhs, auto rhs) noexcept {
return uvsAndHeights[lhs].x > uvsAndHeights[rhs].x;
});
southEdgeIndices = gsl::span(sortEdgeIndices.data(), southVertexCount);
Expand Down Expand Up @@ -556,7 +558,7 @@ static void addSkirts(
eastEdgeIndices.end(),
sortEdgeIndices.begin(),
sortEdgeIndices.begin() + eastVertexCount,
[&uvsAndHeights](auto lhs, auto rhs) {
[&uvsAndHeights](auto lhs, auto rhs) noexcept {
return uvsAndHeights[lhs].y > uvsAndHeights[rhs].y;
});
eastEdgeIndices = gsl::span(sortEdgeIndices.data(), eastVertexCount);
Expand Down Expand Up @@ -587,7 +589,7 @@ static void addSkirts(
northEdgeIndices.end(),
sortEdgeIndices.begin(),
sortEdgeIndices.begin() + northVertexCount,
[&uvsAndHeights](auto lhs, auto rhs) {
[&uvsAndHeights](auto lhs, auto rhs) noexcept {
return uvsAndHeights[lhs].x < uvsAndHeights[rhs].x;
});
northEdgeIndices = gsl::span(sortEdgeIndices.data(), northVertexCount);
Expand Down
2 changes: 1 addition & 1 deletion Cesium3DTilesSelection/src/RasterMappedTo3DTile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RasterOverlayTile* findTileOverlay(Tile& tile, const RasterOverlay& overlay) {
auto parentTileIt = std::find_if(
tiles.begin(),
tiles.end(),
[&overlay](RasterMappedTo3DTile& raster) {
[&overlay](RasterMappedTo3DTile& raster) noexcept {
return raster.getReadyTile() &&
&raster.getReadyTile()->getOverlay() == &overlay;
});
Expand Down
3 changes: 2 additions & 1 deletion Cesium3DTilesSelection/src/RasterOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ void RasterOverlay::loadTileProvider(
pLogger,
this)
.thenInMainThread(
[this](std::unique_ptr<RasterOverlayTileProvider> pProvider) {
[this](
std::unique_ptr<RasterOverlayTileProvider> pProvider) noexcept {
this->_pTileProvider = std::move(pProvider);
this->_isLoadingTileProvider = false;
CESIUM_TRACE_END_IN_TRACK("createTileProvider");
Expand Down
17 changes: 9 additions & 8 deletions Cesium3DTilesSelection/src/RasterOverlayCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ void RasterOverlayCollection::add(std::unique_ptr<RasterOverlay>&& pOverlay) {

void RasterOverlayCollection::remove(RasterOverlay* pOverlay) noexcept {
// Remove all mappings of this overlay to geometry tiles.
auto removeCondition = [pOverlay](const RasterMappedTo3DTile& mapped) {
return (
(mapped.getLoadingTile() &&
&mapped.getLoadingTile()->getOverlay() == pOverlay) ||
(mapped.getReadyTile() &&
&mapped.getReadyTile()->getOverlay() == pOverlay));
};
auto removeCondition =
[pOverlay](const RasterMappedTo3DTile& mapped) noexcept {
return (
(mapped.getLoadingTile() &&
&mapped.getLoadingTile()->getOverlay() == pOverlay) ||
(mapped.getReadyTile() &&
&mapped.getReadyTile()->getOverlay() == pOverlay));
};

this->_pTileset->forEachLoadedTile([&removeCondition](Tile& tile) {
std::vector<RasterMappedTo3DTile>& mapped = tile.getMappedRasterTiles();
Expand All @@ -67,7 +68,7 @@ void RasterOverlayCollection::remove(RasterOverlay* pOverlay) noexcept {
auto it = std::find_if(
this->_overlays.begin(),
this->_overlays.end(),
[pOverlay](std::unique_ptr<RasterOverlay>& pCheck) {
[pOverlay](std::unique_ptr<RasterOverlay>& pCheck) noexcept {
return pCheck.get() == pOverlay;
});
if (it == this->_overlays.end()) {
Expand Down
4 changes: 2 additions & 2 deletions Cesium3DTilesSelection/src/RasterOverlayTileProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void RasterOverlayTileProvider::doLoad(

void RasterOverlayTileProvider::beginTileLoad(
RasterOverlayTile& tile,
bool isThrottledLoad) {
bool isThrottledLoad) noexcept {
// Keep this tile from being destroyed while it's loading.
tile.addReference();

Expand All @@ -342,7 +342,7 @@ void RasterOverlayTileProvider::beginTileLoad(

void RasterOverlayTileProvider::finalizeTileLoad(
RasterOverlayTile& tile,
bool isThrottledLoad) {
bool isThrottledLoad) noexcept {
--this->_totalTilesCurrentlyLoading;
if (isThrottledLoad) {
--this->_throttledTilesCurrentlyLoading;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ RasterizedPolygonsTileExcluder::RasterizedPolygonsTileExcluder(
const RasterizedPolygonsOverlay& overlay) noexcept
: _pOverlay(&overlay) {}

bool RasterizedPolygonsTileExcluder::shouldExclude(const Tile& tile) const {
bool RasterizedPolygonsTileExcluder::shouldExclude(
const Tile& tile) const noexcept {
return Cesium3DTilesSelection::Impl::withinPolygons(
tile.getBoundingVolume(),
this->_pOverlay->getPolygons());
Expand Down
24 changes: 14 additions & 10 deletions Cesium3DTilesSelection/src/Tileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ Tileset::_handleAssetResponse(std::shared_ptr<IAssetRequest>&& pRequest) {
std::move(pContext));
}

static bool operator<(const FogDensityAtHeight& fogDensity, double height) {
static bool
operator<(const FogDensityAtHeight& fogDensity, double height) noexcept {
return fogDensity.cameraHeight < height;
}

Expand Down Expand Up @@ -853,7 +854,7 @@ static std::optional<BoundingVolume> getBoundingVolumeProperty(
*/
static std::string createExtensionsQueryParameter(
const std::vector<std::string>& knownExtensions,
const std::vector<std::string>& extensions) noexcept {
const std::vector<std::string>& extensions) {

std::string extensionsToRequest;
for (const std::string& extension : knownExtensions) {
Expand Down Expand Up @@ -1229,7 +1230,7 @@ static bool isVisibleFromCamera(
* @param fogDensity The fog density
* @return Whether the tile is visible in the fog
*/
static bool isVisibleInFog(double distance, double fogDensity) {
static bool isVisibleInFog(double distance, double fogDensity) noexcept {
if (fogDensity <= 0.0) {
return true;
}
Expand Down Expand Up @@ -1377,7 +1378,9 @@ Tileset::TraversalDetails Tileset::_visitTileIfNeeded(
result);
}

static bool isLeaf(const Tile& tile) { return tile.getChildren().empty(); }
static bool isLeaf(const Tile& tile) noexcept {
return tile.getChildren().empty();
}

Tileset::TraversalDetails Tileset::_renderLeaf(
const FrameState& frameState,
Expand Down Expand Up @@ -1440,7 +1443,7 @@ bool Tileset::_meetsSse(
const std::vector<ViewState>& frustums,
const Tile& tile,
const std::vector<double>& distances,
bool culled) const {
bool culled) const noexcept {

double largestSse = 0.0;

Expand Down Expand Up @@ -1473,7 +1476,7 @@ bool Tileset::_meetsSse(
static bool shouldRenderThisTile(
const Tile& tile,
const TileSelectionState& lastFrameSelectionState,
int32_t lastFrameNumber) {
int32_t lastFrameNumber) noexcept {
TileSelectionState::Result originalResult =
lastFrameSelectionState.getOriginalResult(lastFrameNumber);
if (originalResult == TileSelectionState::Result::Rendered) {
Expand Down Expand Up @@ -1849,7 +1852,7 @@ void Tileset::_processLoadQueue() {
this->_options.maximumSimultaneousTileLoads);
}

void Tileset::_unloadCachedTiles() {
void Tileset::_unloadCachedTiles() noexcept {
const int64_t maxBytes = this->getOptions().maximumCachedBytes;

Tile* pTile = this->_loadedTiles.head();
Expand All @@ -1873,7 +1876,7 @@ void Tileset::_unloadCachedTiles() {
}
}

void Tileset::_markTileVisited(Tile& tile) {
void Tileset::_markTileVisited(Tile& tile) noexcept {
this->_loadedTiles.insertAtTail(tile);
}

Expand Down Expand Up @@ -1936,7 +1939,8 @@ std::string Tileset::getResolvedContentUrl(const Tile& tile) const {
});
}

std::string operator()(UpsampledQuadtreeNode /*subdividedParent*/) {
std::string
operator()(UpsampledQuadtreeNode /*subdividedParent*/) noexcept {
return std::string();
}
};
Expand All @@ -1949,7 +1953,7 @@ std::string Tileset::getResolvedContentUrl(const Tile& tile) const {
return CesiumUtility::Uri::resolve(tile.getContext()->baseUrl, url, true);
}

static bool anyRasterOverlaysNeedLoading(const Tile& tile) {
static bool anyRasterOverlaysNeedLoading(const Tile& tile) noexcept {
for (const RasterMappedTo3DTile& mapped : tile.getMappedRasterTiles()) {
const RasterOverlayTile* pLoading = mapped.getLoadingTile();
if (pLoading &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ const std::map<std::string, GltfFeatureTableType> b3dmComponentTypeToGltfType =
{"DOUBLE", GltfFeatureTableType{"FLOAT64", sizeof(double)}},
};

int64_t roundUp(int64_t num, int64_t multiple) {
int64_t roundUp(int64_t num, int64_t multiple) noexcept {
return ((num + multiple - 1) / multiple) * multiple;
}

template <typename T> bool isInRangeForSignedInteger(int64_t value) {
template <typename T> bool isInRangeForSignedInteger(int64_t value) noexcept {
// this only work if sizeof(T) is smaller than int64_t
static_assert(
!std::is_same_v<T, uint64_t> && !std::is_same_v<T, float> &&
Expand All @@ -74,7 +74,8 @@ template <typename T> bool isInRangeForSignedInteger(int64_t value) {
value <= static_cast<int64_t>(std::numeric_limits<T>::max());
}

template <typename T> bool isInRangeForUnsignedInteger(uint64_t value) {
template <typename T>
bool isInRangeForUnsignedInteger(uint64_t value) noexcept {
static_assert(!std::is_signed_v<T>);

return value >= static_cast<uint64_t>(std::numeric_limits<T>::lowest()) &&
Expand Down
3 changes: 1 addition & 2 deletions CesiumAsync/include/CesiumAsync/Impl/ImmediateScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ template <typename TScheduler> class ImmediateScheduler {

class SchedulerScope {
public:
SchedulerScope(TScheduler* pScheduler = nullptr) noexcept
: _pScheduler(pScheduler) {
SchedulerScope(TScheduler* pScheduler = nullptr) : _pScheduler(pScheduler) {
if (this->_pScheduler) {
std::vector<TScheduler*>& inSuitable =
ImmediateScheduler<TScheduler>::getSchedulersCurrentlyDispatching();
Expand Down
2 changes: 1 addition & 1 deletion CesiumAsync/include/CesiumAsync/ThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CESIUMASYNC_API ThreadPool {
}

static auto createPostRun() noexcept {
return []() { ThreadPool::_scope.reset(); };
return []() noexcept { ThreadPool::_scope.reset(); };
}

static thread_local Impl::ImmediateScheduler<Scheduler>::SchedulerScope
Expand Down
Loading

0 comments on commit a84b09c

Please sign in to comment.