summaryrefslogtreecommitdiff
path: root/src/mbgl/style/sources/geojson_source.cpp
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-11-28 18:19:17 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-11-29 09:53:28 +0200
commitcd4136ed4b4fc5d9a44fe17aa98dfd590c9c0bfb (patch)
tree42e601f7b16a83a62a8418511b795b6dfcf9eeff /src/mbgl/style/sources/geojson_source.cpp
parente3d1daaf6687467ee5c064d2577d2903c508c2dc (diff)
downloadqtlocation-mapboxgl-cd4136ed4b4fc5d9a44fe17aa98dfd590c9c0bfb.tar.gz
[core][android][darwin] Fix GeoJSONOptions handling
- share the `GeoJSONOptions` instances using `Immutable<GeoJSONOptions>` - avoid extra copying - fix wrapping of the `GeoJSONOptions` instances in supercluster map/reduce lambdas. Previously, local variables were wrapped by reference.
Diffstat (limited to 'src/mbgl/style/sources/geojson_source.cpp')
-rw-r--r--src/mbgl/style/sources/geojson_source.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mbgl/style/sources/geojson_source.cpp b/src/mbgl/style/sources/geojson_source.cpp
index 5523336f12..fc8a563fd4 100644
--- a/src/mbgl/style/sources/geojson_source.cpp
+++ b/src/mbgl/style/sources/geojson_source.cpp
@@ -12,8 +12,14 @@
namespace mbgl {
namespace style {
-GeoJSONSource::GeoJSONSource(const std::string& id, optional<GeoJSONOptions> options)
- : Source(makeMutable<Impl>(id, options)) {}
+// static
+Immutable<GeoJSONOptions> GeoJSONOptions::defaultOptions() {
+ static Immutable<GeoJSONOptions> options = makeMutable<GeoJSONOptions>();
+ return options;
+}
+
+GeoJSONSource::GeoJSONSource(std::string id, Immutable<GeoJSONOptions> options)
+ : Source(makeMutable<Impl>(std::move(id), std::move(options))) {}
GeoJSONSource::~GeoJSONSource() = default;
@@ -47,7 +53,7 @@ optional<std::string> GeoJSONSource::getURL() const {
}
const GeoJSONOptions& GeoJSONSource::getOptions() const {
- return impl().getOptions();
+ return *impl().getOptions();
}
void GeoJSONSource::loadDescription(FileSource& fileSource) {