diff --git a/src/mbgl/layermanager/background_layer_factory.cpp b/src/mbgl/layermanager/background_layer_factory.cpp index d711d3ec5..fddcf4929 100644 --- a/src/mbgl/layermanager/background_layer_factory.cpp +++ b/src/mbgl/layermanager/background_layer_factory.cpp @@ -13,7 +13,7 @@ const style::LayerTypeInfo* BackgroundLayerFactory::getTypeInfo() const noexcept std::unique_ptr BackgroundLayerFactory::createLayer( const std::string& id, const style::conversion::Convertible& value) noexcept { (void)value; - return std::unique_ptr(new style::BackgroundLayer(id)); + return std::unique_ptr(new (std::nothrow) style::BackgroundLayer(id)); } std::unique_ptr BackgroundLayerFactory::createRenderLayer(Immutable impl) noexcept { diff --git a/src/mbgl/layermanager/circle_layer_factory.cpp b/src/mbgl/layermanager/circle_layer_factory.cpp index b32fb1317..e92b0a536 100644 --- a/src/mbgl/layermanager/circle_layer_factory.cpp +++ b/src/mbgl/layermanager/circle_layer_factory.cpp @@ -14,24 +14,22 @@ const style::LayerTypeInfo* CircleLayerFactory::getTypeInfo() const noexcept { std::unique_ptr 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(new style::CircleLayer(id, *source)); + const auto source = getSource(value); + return std::unique_ptr(source ? new (std::nothrow) style::CircleLayer(id, *source) : nullptr); } std::unique_ptr CircleLayerFactory::createLayout( const LayoutParameters& parameters, std::unique_ptr layer, const std::vector>& group) noexcept { - return std::make_unique(parameters.bucketParameters, group, std::move(layer)); + return std::unique_ptr(new (std::nothrow) + CircleLayout(parameters.bucketParameters, group, std::move(layer))); } std::unique_ptr CircleLayerFactory::createRenderLayer(Immutable impl) noexcept { assert(impl->getTypeInfo() == getTypeInfo()); - return std::make_unique(staticImmutableCast(impl)); + return std::unique_ptr(new (std::nothrow) + RenderCircleLayer(staticImmutableCast(impl))); } } // namespace mbgl diff --git a/src/mbgl/layermanager/fill_extrusion_layer_factory.cpp b/src/mbgl/layermanager/fill_extrusion_layer_factory.cpp index 8c78f630c..cf757022f 100644 --- a/src/mbgl/layermanager/fill_extrusion_layer_factory.cpp +++ b/src/mbgl/layermanager/fill_extrusion_layer_factory.cpp @@ -13,12 +13,8 @@ const style::LayerTypeInfo* FillExtrusionLayerFactory::getTypeInfo() const noexc std::unique_ptr 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(new style::FillExtrusionLayer(id, *source)); + const auto source = getSource(value); + return std::unique_ptr(source ? new (std::nothrow) style::FillExtrusionLayer(id, *source) : nullptr); } std::unique_ptr FillExtrusionLayerFactory::createLayout( @@ -27,12 +23,14 @@ std::unique_ptr FillExtrusionLayerFactory::createLayout( const std::vector>& group) noexcept { using namespace style; using LayoutType = PatternLayout; - return std::make_unique(parameters.bucketParameters, group, std::move(layer), parameters); + return std::unique_ptr(new (std::nothrow) + LayoutType(parameters.bucketParameters, group, std::move(layer), parameters)); } std::unique_ptr FillExtrusionLayerFactory::createRenderLayer(Immutable impl) noexcept { assert(impl->getTypeInfo() == getTypeInfo()); - return std::make_unique(staticImmutableCast(impl)); + auto renderImpl = staticImmutableCast(impl); + return std::unique_ptr(new (std::nothrow) RenderFillExtrusionLayer(std::move(renderImpl))); } } // namespace mbgl diff --git a/src/mbgl/layermanager/fill_layer_factory.cpp b/src/mbgl/layermanager/fill_layer_factory.cpp index 5f2de1ed1..f7faf3ac0 100644 --- a/src/mbgl/layermanager/fill_layer_factory.cpp +++ b/src/mbgl/layermanager/fill_layer_factory.cpp @@ -27,14 +27,17 @@ std::unique_ptr FillLayerFactory::createLayout( PatternLayout; auto layerProperties = staticImmutableCast(group.front()); if (layerProperties->layerImpl().layout.get().isUndefined()) { - return std::make_unique(parameters.bucketParameters, group, std::move(layer), parameters); + return std::unique_ptr( + new (std::nothrow) LayoutTypeUnsorted(parameters.bucketParameters, group, std::move(layer), parameters)); } - return std::make_unique(parameters.bucketParameters, group, std::move(layer), parameters); + return std::unique_ptr( + new (std::nothrow) LayoutTypeSorted(parameters.bucketParameters, group, std::move(layer), parameters)); } std::unique_ptr FillLayerFactory::createRenderLayer(Immutable impl) noexcept { assert(impl->getTypeInfo() == getTypeInfo()); - return std::make_unique(staticImmutableCast(impl)); + auto fillImpl = staticImmutableCast(impl); + return std::unique_ptr(new (std::nothrow) RenderFillLayer(std::move(fillImpl))); } } // namespace mbgl diff --git a/src/mbgl/layermanager/heatmap_layer_factory.cpp b/src/mbgl/layermanager/heatmap_layer_factory.cpp index 17bbd71fc..77c3e8581 100644 --- a/src/mbgl/layermanager/heatmap_layer_factory.cpp +++ b/src/mbgl/layermanager/heatmap_layer_factory.cpp @@ -13,12 +13,11 @@ const style::LayerTypeInfo* HeatmapLayerFactory::getTypeInfo() const noexcept { std::unique_ptr 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(new style::HeatmapLayer(id, *source)); + return std::unique_ptr(new (std::nothrow) style::HeatmapLayer(id, *source)); } std::unique_ptr HeatmapLayerFactory::createBucket( diff --git a/src/mbgl/layermanager/hillshade_layer_factory.cpp b/src/mbgl/layermanager/hillshade_layer_factory.cpp index af257d1c9..11fca6a58 100644 --- a/src/mbgl/layermanager/hillshade_layer_factory.cpp +++ b/src/mbgl/layermanager/hillshade_layer_factory.cpp @@ -12,13 +12,11 @@ const style::LayerTypeInfo* HillshadeLayerFactory::getTypeInfo() const noexcept std::unique_ptr 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 layer = std::unique_ptr(new style::HillshadeLayer(id, *source)); - return layer; + return std::unique_ptr(new (std::nothrow) style::HillshadeLayer(id, *source)); } std::unique_ptr HillshadeLayerFactory::createRenderLayer(Immutable impl) noexcept { diff --git a/src/mbgl/layermanager/line_layer_factory.cpp b/src/mbgl/layermanager/line_layer_factory.cpp index 2ff372a4a..ca6778801 100644 --- a/src/mbgl/layermanager/line_layer_factory.cpp +++ b/src/mbgl/layermanager/line_layer_factory.cpp @@ -13,11 +13,8 @@ const style::LayerTypeInfo* LineLayerFactory::getTypeInfo() const noexcept { std::unique_ptr 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(new style::LineLayer(id, *source)); + const auto source = getSource(value); + return std::unique_ptr(source ? new (std::nothrow) style::LineLayer(id, *source) : nullptr); } std::unique_ptr LineLayerFactory::createLayout( @@ -30,14 +27,17 @@ std::unique_ptr LineLayerFactory::createLayout( PatternLayout; auto layerProperties = staticImmutableCast(group.front()); if (layerProperties->layerImpl().layout.get().isUndefined()) { - return std::make_unique(parameters.bucketParameters, group, std::move(layer), parameters); + return std::unique_ptr( + new (std::nothrow) LayoutTypeUnsorted(parameters.bucketParameters, group, std::move(layer), parameters)); } - return std::make_unique(parameters.bucketParameters, group, std::move(layer), parameters); + return std::unique_ptr( + new (std::nothrow) LayoutTypeSorted(parameters.bucketParameters, group, std::move(layer), parameters)); } std::unique_ptr LineLayerFactory::createRenderLayer(Immutable impl) noexcept { assert(impl->getTypeInfo() == getTypeInfo()); - return std::make_unique(staticImmutableCast(impl)); + auto lineImpl = staticImmutableCast(impl); + return std::unique_ptr(new (std::nothrow) RenderLineLayer(std::move(lineImpl))); } } // namespace mbgl diff --git a/src/mbgl/layermanager/raster_layer_factory.cpp b/src/mbgl/layermanager/raster_layer_factory.cpp index 05fc9fd66..8b9909202 100644 --- a/src/mbgl/layermanager/raster_layer_factory.cpp +++ b/src/mbgl/layermanager/raster_layer_factory.cpp @@ -12,13 +12,11 @@ const style::LayerTypeInfo* RasterLayerFactory::getTypeInfo() const noexcept { std::unique_ptr 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 layer = std::unique_ptr(new style::RasterLayer(id, *source)); - return layer; + return std::unique_ptr(new (std::nothrow) style::RasterLayer(id, *source)); } std::unique_ptr RasterLayerFactory::createRenderLayer(Immutable impl) noexcept { diff --git a/src/mbgl/layermanager/symbol_layer_factory.cpp b/src/mbgl/layermanager/symbol_layer_factory.cpp index 465341fb6..3c4d2c4d2 100644 --- a/src/mbgl/layermanager/symbol_layer_factory.cpp +++ b/src/mbgl/layermanager/symbol_layer_factory.cpp @@ -13,18 +13,16 @@ const style::LayerTypeInfo* SymbolLayerFactory::getTypeInfo() const noexcept { std::unique_ptr SymbolLayerFactory::createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept { - std::optional source = getSource(value); - if (!source) { - return nullptr; - } - return std::unique_ptr(new style::SymbolLayer(id, *source)); + const auto source = getSource(value); + return std::unique_ptr(source ? new (std::nothrow) style::SymbolLayer(id, *source) : nullptr); } std::unique_ptr SymbolLayerFactory::createLayout( const LayoutParameters& parameters, std::unique_ptr tileLayer, const std::vector>& group) noexcept { - return std::make_unique(parameters.bucketParameters, group, std::move(tileLayer), parameters); + return std::unique_ptr( + new (std::nothrow) SymbolLayout(parameters.bucketParameters, group, std::move(tileLayer), parameters)); } std::unique_ptr SymbolLayerFactory::createRenderLayer(Immutable impl) noexcept {