Consistently use no-throw new in noexcept layer create methods (#1875)
This commit is contained in:
@@ -13,7 +13,7 @@ const style::LayerTypeInfo* BackgroundLayerFactory::getTypeInfo() const noexcept
|
||||
std::unique_ptr<style::Layer> BackgroundLayerFactory::createLayer(
|
||||
const std::string& id, const style::conversion::Convertible& value) noexcept {
|
||||
(void)value;
|
||||
return std::unique_ptr<style::Layer>(new style::BackgroundLayer(id));
|
||||
return std::unique_ptr<style::Layer>(new (std::nothrow) style::BackgroundLayer(id));
|
||||
}
|
||||
|
||||
std::unique_ptr<RenderLayer> BackgroundLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
|
||||
|
||||
@@ -14,24 +14,22 @@ const style::LayerTypeInfo* CircleLayerFactory::getTypeInfo() const noexcept {
|
||||
|
||||
std::unique_ptr<style::Layer> CircleLayerFactory::createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept {
|
||||
auto const source = getSource(value);
|
||||
if (!source) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return std::unique_ptr<style::Layer>(new style::CircleLayer(id, *source));
|
||||
const auto source = getSource(value);
|
||||
return std::unique_ptr<style::Layer>(source ? new (std::nothrow) style::CircleLayer(id, *source) : nullptr);
|
||||
}
|
||||
|
||||
std::unique_ptr<Layout> CircleLayerFactory::createLayout(
|
||||
const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> layer,
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) noexcept {
|
||||
return std::make_unique<CircleLayout>(parameters.bucketParameters, group, std::move(layer));
|
||||
return std::unique_ptr<Layout>(new (std::nothrow)
|
||||
CircleLayout(parameters.bucketParameters, group, std::move(layer)));
|
||||
}
|
||||
|
||||
std::unique_ptr<RenderLayer> CircleLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
|
||||
assert(impl->getTypeInfo() == getTypeInfo());
|
||||
return std::make_unique<RenderCircleLayer>(staticImmutableCast<style::CircleLayer::Impl>(impl));
|
||||
return std::unique_ptr<RenderLayer>(new (std::nothrow)
|
||||
RenderCircleLayer(staticImmutableCast<style::CircleLayer::Impl>(impl)));
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -13,12 +13,8 @@ const style::LayerTypeInfo* FillExtrusionLayerFactory::getTypeInfo() const noexc
|
||||
|
||||
std::unique_ptr<style::Layer> FillExtrusionLayerFactory::createLayer(
|
||||
const std::string& id, const style::conversion::Convertible& value) noexcept {
|
||||
auto const source = getSource(value);
|
||||
if (!source) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return std::unique_ptr<style::Layer>(new style::FillExtrusionLayer(id, *source));
|
||||
const auto source = getSource(value);
|
||||
return std::unique_ptr<style::Layer>(source ? new (std::nothrow) style::FillExtrusionLayer(id, *source) : nullptr);
|
||||
}
|
||||
|
||||
std::unique_ptr<Layout> FillExtrusionLayerFactory::createLayout(
|
||||
@@ -27,12 +23,14 @@ std::unique_ptr<Layout> FillExtrusionLayerFactory::createLayout(
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) noexcept {
|
||||
using namespace style;
|
||||
using LayoutType = PatternLayout<FillExtrusionBucket, FillExtrusionLayerProperties, FillExtrusionPattern>;
|
||||
return std::make_unique<LayoutType>(parameters.bucketParameters, group, std::move(layer), parameters);
|
||||
return std::unique_ptr<Layout>(new (std::nothrow)
|
||||
LayoutType(parameters.bucketParameters, group, std::move(layer), parameters));
|
||||
}
|
||||
|
||||
std::unique_ptr<RenderLayer> FillExtrusionLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
|
||||
assert(impl->getTypeInfo() == getTypeInfo());
|
||||
return std::make_unique<RenderFillExtrusionLayer>(staticImmutableCast<style::FillExtrusionLayer::Impl>(impl));
|
||||
auto renderImpl = staticImmutableCast<style::FillExtrusionLayer::Impl>(impl);
|
||||
return std::unique_ptr<RenderLayer>(new (std::nothrow) RenderFillExtrusionLayer(std::move(renderImpl)));
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -27,14 +27,17 @@ std::unique_ptr<Layout> FillLayerFactory::createLayout(
|
||||
PatternLayout<FillBucket, FillLayerProperties, FillPattern, FillLayoutProperties, FillSortKey>;
|
||||
auto layerProperties = staticImmutableCast<FillLayerProperties>(group.front());
|
||||
if (layerProperties->layerImpl().layout.get<FillSortKey>().isUndefined()) {
|
||||
return std::make_unique<LayoutTypeUnsorted>(parameters.bucketParameters, group, std::move(layer), parameters);
|
||||
return std::unique_ptr<Layout>(
|
||||
new (std::nothrow) LayoutTypeUnsorted(parameters.bucketParameters, group, std::move(layer), parameters));
|
||||
}
|
||||
return std::make_unique<LayoutTypeSorted>(parameters.bucketParameters, group, std::move(layer), parameters);
|
||||
return std::unique_ptr<Layout>(
|
||||
new (std::nothrow) LayoutTypeSorted(parameters.bucketParameters, group, std::move(layer), parameters));
|
||||
}
|
||||
|
||||
std::unique_ptr<RenderLayer> FillLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
|
||||
assert(impl->getTypeInfo() == getTypeInfo());
|
||||
return std::make_unique<RenderFillLayer>(staticImmutableCast<style::FillLayer::Impl>(impl));
|
||||
auto fillImpl = staticImmutableCast<style::FillLayer::Impl>(impl);
|
||||
return std::unique_ptr<RenderLayer>(new (std::nothrow) RenderFillLayer(std::move(fillImpl)));
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -13,12 +13,11 @@ const style::LayerTypeInfo* HeatmapLayerFactory::getTypeInfo() const noexcept {
|
||||
|
||||
std::unique_ptr<style::Layer> HeatmapLayerFactory::createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept {
|
||||
auto const source = getSource(value);
|
||||
const auto source = getSource(value);
|
||||
if (!source) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return std::unique_ptr<style::Layer>(new style::HeatmapLayer(id, *source));
|
||||
return std::unique_ptr<style::Layer>(new (std::nothrow) style::HeatmapLayer(id, *source));
|
||||
}
|
||||
|
||||
std::unique_ptr<Bucket> HeatmapLayerFactory::createBucket(
|
||||
|
||||
@@ -12,13 +12,11 @@ const style::LayerTypeInfo* HillshadeLayerFactory::getTypeInfo() const noexcept
|
||||
|
||||
std::unique_ptr<style::Layer> HillshadeLayerFactory::createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept {
|
||||
auto const source = getSource(value);
|
||||
const auto source = getSource(value);
|
||||
if (!source) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new style::HillshadeLayer(id, *source));
|
||||
return layer;
|
||||
return std::unique_ptr<style::Layer>(new (std::nothrow) style::HillshadeLayer(id, *source));
|
||||
}
|
||||
|
||||
std::unique_ptr<RenderLayer> HillshadeLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
|
||||
|
||||
@@ -13,11 +13,8 @@ const style::LayerTypeInfo* LineLayerFactory::getTypeInfo() const noexcept {
|
||||
|
||||
std::unique_ptr<style::Layer> LineLayerFactory::createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept {
|
||||
auto const source = getSource(value);
|
||||
if (!source) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::unique_ptr<style::Layer>(new style::LineLayer(id, *source));
|
||||
const auto source = getSource(value);
|
||||
return std::unique_ptr<style::Layer>(source ? new (std::nothrow) style::LineLayer(id, *source) : nullptr);
|
||||
}
|
||||
|
||||
std::unique_ptr<Layout> LineLayerFactory::createLayout(
|
||||
@@ -30,14 +27,17 @@ std::unique_ptr<Layout> LineLayerFactory::createLayout(
|
||||
PatternLayout<LineBucket, LineLayerProperties, LinePattern, LineLayoutProperties, LineSortKey>;
|
||||
auto layerProperties = staticImmutableCast<LineLayerProperties>(group.front());
|
||||
if (layerProperties->layerImpl().layout.get<LineSortKey>().isUndefined()) {
|
||||
return std::make_unique<LayoutTypeUnsorted>(parameters.bucketParameters, group, std::move(layer), parameters);
|
||||
return std::unique_ptr<Layout>(
|
||||
new (std::nothrow) LayoutTypeUnsorted(parameters.bucketParameters, group, std::move(layer), parameters));
|
||||
}
|
||||
return std::make_unique<LayoutTypeSorted>(parameters.bucketParameters, group, std::move(layer), parameters);
|
||||
return std::unique_ptr<Layout>(
|
||||
new (std::nothrow) LayoutTypeSorted(parameters.bucketParameters, group, std::move(layer), parameters));
|
||||
}
|
||||
|
||||
std::unique_ptr<RenderLayer> LineLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
|
||||
assert(impl->getTypeInfo() == getTypeInfo());
|
||||
return std::make_unique<RenderLineLayer>(staticImmutableCast<style::LineLayer::Impl>(impl));
|
||||
auto lineImpl = staticImmutableCast<style::LineLayer::Impl>(impl);
|
||||
return std::unique_ptr<RenderLayer>(new (std::nothrow) RenderLineLayer(std::move(lineImpl)));
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -12,13 +12,11 @@ const style::LayerTypeInfo* RasterLayerFactory::getTypeInfo() const noexcept {
|
||||
|
||||
std::unique_ptr<style::Layer> RasterLayerFactory::createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept {
|
||||
auto const source = getSource(value);
|
||||
const auto source = getSource(value);
|
||||
if (!source) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new style::RasterLayer(id, *source));
|
||||
return layer;
|
||||
return std::unique_ptr<style::Layer>(new (std::nothrow) style::RasterLayer(id, *source));
|
||||
}
|
||||
|
||||
std::unique_ptr<RenderLayer> RasterLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
|
||||
|
||||
@@ -13,18 +13,16 @@ const style::LayerTypeInfo* SymbolLayerFactory::getTypeInfo() const noexcept {
|
||||
|
||||
std::unique_ptr<style::Layer> SymbolLayerFactory::createLayer(const std::string& id,
|
||||
const style::conversion::Convertible& value) noexcept {
|
||||
std::optional<std::string> source = getSource(value);
|
||||
if (!source) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::unique_ptr<style::Layer>(new style::SymbolLayer(id, *source));
|
||||
const auto source = getSource(value);
|
||||
return std::unique_ptr<style::Layer>(source ? new (std::nothrow) style::SymbolLayer(id, *source) : nullptr);
|
||||
}
|
||||
|
||||
std::unique_ptr<Layout> SymbolLayerFactory::createLayout(
|
||||
const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> tileLayer,
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) noexcept {
|
||||
return std::make_unique<SymbolLayout>(parameters.bucketParameters, group, std::move(tileLayer), parameters);
|
||||
return std::unique_ptr<Layout>(
|
||||
new (std::nothrow) SymbolLayout(parameters.bucketParameters, group, std::move(tileLayer), parameters));
|
||||
}
|
||||
|
||||
std::unique_ptr<RenderLayer> SymbolLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
|
||||
|
||||
Reference in New Issue
Block a user