avoid style, layer, and fontset copies in load_map - refs #2453
This commit is contained in:
parent
32f80b2b3e
commit
aae56fa387
2 changed files with 49 additions and 9 deletions
|
@ -166,13 +166,21 @@ public:
|
|||
*/
|
||||
style_iterator end_styles();
|
||||
|
||||
/*! \brief Insert a style in the map.
|
||||
/*! \brief Insert a style in the map by copying.
|
||||
* @param name The name of the style.
|
||||
* @param style The style to insert.
|
||||
* @return true If success.
|
||||
* false If no success.
|
||||
*/
|
||||
bool insert_style(std::string const& name,feature_type_style style);
|
||||
bool insert_style(std::string const& name,feature_type_style const& style);
|
||||
|
||||
/*! \brief Insert a style in the map by moving..
|
||||
* @param name The name of the style.
|
||||
* @param style The style to insert.
|
||||
* @return true If success.
|
||||
* false If no success.
|
||||
*/
|
||||
bool insert_style(std::string const& name,feature_type_style && style);
|
||||
|
||||
/*! \brief Remove a style from the map.
|
||||
* @param name The name of the style.
|
||||
|
@ -185,13 +193,21 @@ public:
|
|||
*/
|
||||
boost::optional<feature_type_style const&> find_style(std::string const& name) const;
|
||||
|
||||
/*! \brief Insert a fontset into the map.
|
||||
/*! \brief Insert a fontset into the map by copying.
|
||||
* @param name The name of the fontset.
|
||||
* @param fontset The fontset to insert.
|
||||
* @return true If success.
|
||||
* false If failure.
|
||||
*/
|
||||
bool insert_fontset(std::string const& name, font_set fontset);
|
||||
bool insert_fontset(std::string const& name, font_set const& fontset);
|
||||
|
||||
/*! \brief Insert a fontset into the map by moving.
|
||||
* @param name The name of the fontset.
|
||||
* @param fontset The fontset to insert.
|
||||
* @return true If success.
|
||||
* false If failure.
|
||||
*/
|
||||
bool insert_fontset(std::string const& name, font_set && fontset);
|
||||
|
||||
/*! \brief Find a fontset.
|
||||
* @param name The name of the fontset.
|
||||
|
@ -213,10 +229,15 @@ public:
|
|||
*/
|
||||
size_t layer_count() const;
|
||||
|
||||
/*! \brief Add a layer to the map.
|
||||
/*! \brief Add a layer to the map by copying it.
|
||||
* @param l The layer to add.
|
||||
*/
|
||||
void add_layer(layer l);
|
||||
void add_layer(layer const& l);
|
||||
|
||||
/*! \brief Add a layer to the map by moving it.
|
||||
* @param l The layer to add.
|
||||
*/
|
||||
void insert_layer(layer && l);
|
||||
|
||||
/*! \brief Get a layer.
|
||||
* @param index layer number.
|
||||
|
|
25
src/map.cpp
25
src/map.cpp
|
@ -200,7 +200,12 @@ Map::const_style_iterator Map::end_styles() const
|
|||
return styles_.end();
|
||||
}
|
||||
|
||||
bool Map::insert_style(std::string const& name,feature_type_style style)
|
||||
bool Map::insert_style(std::string const& name, feature_type_style const& style)
|
||||
{
|
||||
return styles_.emplace(name, style).second;
|
||||
}
|
||||
|
||||
bool Map::insert_style(std::string const& name, feature_type_style && style)
|
||||
{
|
||||
return styles_.emplace(name, std::move(style)).second;
|
||||
}
|
||||
|
@ -219,7 +224,16 @@ boost::optional<feature_type_style const&> Map::find_style(std::string const& na
|
|||
return boost::optional<feature_type_style const&>() ;
|
||||
}
|
||||
|
||||
bool Map::insert_fontset(std::string const& name, font_set fontset)
|
||||
bool Map::insert_fontset(std::string const& name, font_set const& fontset)
|
||||
{
|
||||
if (fontset.get_name() != name)
|
||||
{
|
||||
throw mapnik::config_error("Fontset name must match the name used to reference it on the map");
|
||||
}
|
||||
return fontsets_.emplace(name, fontset).second;
|
||||
}
|
||||
|
||||
bool Map::insert_fontset(std::string const& name, font_set && fontset)
|
||||
{
|
||||
if (fontset.get_name() != name)
|
||||
{
|
||||
|
@ -252,7 +266,12 @@ size_t Map::layer_count() const
|
|||
return layers_.size();
|
||||
}
|
||||
|
||||
void Map::add_layer(layer l)
|
||||
void Map::add_layer(layer const& l)
|
||||
{
|
||||
layers_.emplace_back(l);
|
||||
}
|
||||
|
||||
void Map::insert_layer(layer && l)
|
||||
{
|
||||
layers_.push_back(std::move(l));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue