From 167097936acbc77fe91bbf73ee59f447f8a10b9a Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 25 Nov 2014 18:09:38 -0800 Subject: [PATCH] Store SourceInfo as direct member --- include/mbgl/style/style_source.hpp | 9 ++------- src/map/map.cpp | 2 +- src/style/style_parser.cpp | 12 +++++------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/include/mbgl/style/style_source.hpp b/include/mbgl/style/style_source.hpp index 86473079c..8c7d02888 100644 --- a/include/mbgl/style/style_source.hpp +++ b/include/mbgl/style/style_source.hpp @@ -29,16 +29,11 @@ public: }; -class StyleSource : public std::enable_shared_from_this { +class StyleSource : private util::noncopyable { public: - util::ptr info; - + SourceInfo info; bool enabled = false; util::ptr source; - - StyleSource(const util::ptr &info_) - : info(info_) - {} }; } diff --git a/src/map/map.cpp b/src/map/map.cpp index 2df3e068f..eb0a48d8d 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -606,7 +606,7 @@ void Map::updateSources() { for (const util::ptr &style_source : activeSources) { if (style_source->enabled) { if (!style_source->source) { - style_source->source = std::make_shared(*style_source->info); + style_source->source = std::make_shared(style_source->info); style_source->source->load(*this, *fileSource); } } else { diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index fa51e48ce..22d43df44 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -178,14 +178,12 @@ void StyleParser::parseSources(JSVal value) { rapidjson::Value::ConstMemberIterator itr = value.MemberBegin(); for (; itr != value.MemberEnd(); ++itr) { std::string name { itr->name.GetString(), itr->name.GetStringLength() }; - util::ptr info = std::make_shared(); + SourceInfo& info = sources.emplace(name, std::make_shared()).first->second->info; - parseRenderProperty(itr->value, info->type, "type"); - parseRenderProperty(itr->value, info->url, "url"); - parseRenderProperty(itr->value, info->tile_size, "tileSize"); - info->parseTileJSONProperties(itr->value); - - sources.emplace(std::move(name), std::make_shared(info)); + parseRenderProperty(itr->value, info.type, "type"); + parseRenderProperty(itr->value, info.url, "url"); + parseRenderProperty(itr->value, info.tile_size, "tileSize"); + info.parseTileJSONProperties(itr->value); } } else { Log::Warning(Event::ParseStyle, "sources must be an object");