Merge pull request #2345 from mapnik/emplace
use emplace/emplace_back over insert/push_back - refs #2336
This commit is contained in:
commit
8f183ac63a
20 changed files with 35 additions and 41 deletions
|
@ -56,7 +56,7 @@ struct expression_attributes : boost::static_visitor<void>
|
|||
|
||||
void operator() (attribute const& attr) const
|
||||
{
|
||||
names_.insert(attr.name());
|
||||
names_.emplace(attr.name());
|
||||
}
|
||||
|
||||
template <typename Tag>
|
||||
|
@ -289,7 +289,7 @@ inline void group_attribute_collector::operator() (group_symbolizer const& sym)
|
|||
{
|
||||
std::string col_idx_name = col_name;
|
||||
boost::replace_all(col_idx_name, "%", col_idx_str);
|
||||
names_.insert(col_idx_name);
|
||||
names_.emplace(col_idx_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ inline void group_attribute_collector::operator() (group_symbolizer const& sym)
|
|||
{
|
||||
// This is not an indexed column, or we are ignoring indexes.
|
||||
// Insert the name as is.
|
||||
names_.insert(col_name);
|
||||
names_.emplace(col_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,13 +67,13 @@ public:
|
|||
inline size_type push(key_type const& name)
|
||||
{
|
||||
size_type index = mapping_.size();
|
||||
mapping_.insert(std::make_pair(name, index));
|
||||
mapping_.emplace(name, index);
|
||||
return index;
|
||||
}
|
||||
|
||||
inline void add(key_type const& name, size_type index)
|
||||
{
|
||||
mapping_.insert(std::make_pair(name, index));
|
||||
mapping_.emplace(name, index);
|
||||
}
|
||||
|
||||
inline size_type size() const { return mapping_.size(); }
|
||||
|
|
|
@ -268,7 +268,7 @@ void render_group_symbolizer(group_symbolizer const& sym,
|
|||
*(rule->get_filter())).to_bool())
|
||||
{
|
||||
// add matched rule and feature to the list of things to draw
|
||||
matches.push_back(std::make_pair(rule, sub_feature));
|
||||
matches.emplace_back(rule, sub_feature);
|
||||
|
||||
// construct a bounding box around all symbolizers for the matched rule
|
||||
bound_box bounds;
|
||||
|
|
|
@ -311,10 +311,7 @@ struct put_impl
|
|||
}
|
||||
else
|
||||
{
|
||||
// NOTE: we use insert here instead of emplace
|
||||
// because of lacking std::map emplace support in libstdc++
|
||||
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44436
|
||||
sym.properties.insert(std::make_pair(key, enumeration_wrapper(val)));
|
||||
sym.properties.emplace(key, enumeration_wrapper(val));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -331,7 +328,7 @@ struct put_impl<T, false>
|
|||
}
|
||||
else
|
||||
{
|
||||
sym.properties.insert(std::make_pair(key, val));
|
||||
sym.properties.emplace(key, val);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -196,13 +196,13 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order)
|
|||
if (command == SEG_MOVETO)
|
||||
{
|
||||
rings.push_back(new linear_ring); // start new loop
|
||||
rings.back().push_back(std::make_pair(x,y));
|
||||
rings.back().emplace_back(x,y);
|
||||
size += 4; // num_points
|
||||
size += 2 * 8; // point
|
||||
}
|
||||
else if (command == SEG_LINETO)
|
||||
{
|
||||
rings.back().push_back(std::make_pair(x,y));
|
||||
rings.back().emplace_back(x,y);
|
||||
size += 2 * 8; // point
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ struct do_xml_attribute_cast<mapnik::expression_ptr>
|
|||
else
|
||||
{
|
||||
mapnik::expression_ptr expr = parse_expression(source);
|
||||
tree.expr_cache_.insert(std::make_pair(source,expr));
|
||||
tree.expr_cache_.emplace(source,expr);
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -684,7 +684,7 @@ processor_context_ptr postgis_datasource::get_context(feature_style_context_map
|
|||
}
|
||||
else
|
||||
{
|
||||
return ctx.insert(std::make_pair(ds_name,std::make_shared<postgis_processor_context>())).first->second;
|
||||
return ctx.emplace(ds_name,std::make_shared<postgis_processor_context>()).first->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ python_datasource::python_datasource(parameters const& params)
|
|||
{
|
||||
if((kv.first != "type") && (kv.first != "factory"))
|
||||
{
|
||||
kwargs_.insert(std::make_pair(kv.first, *params.get<std::string>(kv.first)));
|
||||
kwargs_.emplace(kv.first, *params.get<std::string>(kv.first));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -525,9 +525,8 @@ cairo_face_ptr cairo_face_manager::get_face(face_ptr face)
|
|||
else
|
||||
{
|
||||
entry = std::make_shared<cairo_face>(font_engine_, face);
|
||||
cache_.insert(std::make_pair(face, entry));
|
||||
cache_.emplace(face, entry);
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ bool datasource_cache::register_datasource(std::string const& filename)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (plugins_.insert(std::make_pair(plugin->name(),plugin)).second)
|
||||
if (plugins_.emplace(plugin->name(),plugin).second)
|
||||
{
|
||||
MAPNIK_LOG_DEBUG(datasource_cache)
|
||||
<< "datasource_cache: Registered="
|
||||
|
|
|
@ -177,7 +177,7 @@ bool freetype_engine::register_font_impl(std::string const& file_name, FT_Librar
|
|||
// skip fonts with leading . in the name
|
||||
if (!boost::algorithm::starts_with(name,"."))
|
||||
{
|
||||
name2file_.insert(std::make_pair(name, std::make_pair(i,file_name)));
|
||||
name2file_.emplace(name,std::make_pair(i,file_name));
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ face_ptr freetype_engine::create_face(std::string const& family_name)
|
|||
std::fseek(file.get(), 0, SEEK_SET);
|
||||
std::unique_ptr<char[]> buffer(new char[file_size]);
|
||||
std::fread(buffer.get(), file_size, 1, file.get());
|
||||
auto result = memory_fonts_.insert(std::make_pair(itr->second.second, std::make_pair(std::move(buffer),file_size)));
|
||||
auto result = memory_fonts_.emplace(itr->second.second, std::make_pair(std::move(buffer),file_size));
|
||||
FT_Error error = FT_New_Memory_Face (library_,
|
||||
reinterpret_cast<FT_Byte const*>(result.first->second.first.get()),
|
||||
static_cast<FT_Long>(result.first->second.second),
|
||||
|
@ -377,7 +377,7 @@ face_ptr face_manager<T>::get_face(std::string const& name)
|
|||
face_ptr face = engine_.create_face(name);
|
||||
if (face)
|
||||
{
|
||||
face_ptr_cache_.insert(make_pair(name,face));
|
||||
face_ptr_cache_.emplace(name,face);
|
||||
}
|
||||
return face;
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ void hit_grid<T>::add_feature(mapnik::feature_impl const& feature)
|
|||
{
|
||||
// TODO - consider shortcutting f_keys if feature_id == lookup_value
|
||||
// create a mapping between the pixel id and the feature key
|
||||
f_keys_.insert(std::make_pair(feature_id,lookup_value));
|
||||
f_keys_.emplace(feature_id,lookup_value);
|
||||
// if extra fields have been supplied, push them into grid memory
|
||||
if (!names_.empty())
|
||||
{
|
||||
|
@ -136,7 +136,7 @@ void hit_grid<T>::add_feature(mapnik::feature_impl const& feature)
|
|||
// https://github.com/mapnik/mapnik/issues/1198
|
||||
mapnik::feature_ptr feature2(mapnik::feature_factory::create(ctx_,feature_id));
|
||||
feature2->set_data(feature.get_data());
|
||||
features_.insert(std::make_pair(lookup_value,feature2));
|
||||
features_.emplace(lookup_value,feature2);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -501,7 +501,7 @@ void map_parser::parse_fontset(Map & map, xml_node const& node)
|
|||
|
||||
// XXX Hack because map object isn't accessible by text_symbolizer
|
||||
// when it's parsed
|
||||
fontsets_.insert(std::make_pair(name, fontset));
|
||||
fontsets_.emplace(name, fontset);
|
||||
map.insert_fontset(name, std::move(fontset));
|
||||
}
|
||||
catch (config_error const& ex)
|
||||
|
|
|
@ -201,7 +201,7 @@ Map::const_style_iterator Map::end_styles() const
|
|||
|
||||
bool Map::insert_style(std::string const& name,feature_type_style style)
|
||||
{
|
||||
return styles_.insert(make_pair(name, std::move(style))).second;
|
||||
return styles_.emplace(name, std::move(style)).second;
|
||||
}
|
||||
|
||||
void Map::remove_style(std::string const& name)
|
||||
|
@ -224,7 +224,7 @@ bool Map::insert_fontset(std::string const& name, font_set fontset)
|
|||
{
|
||||
throw mapnik::config_error("Fontset name must match the name used to reference it on the map");
|
||||
}
|
||||
return fontsets_.insert(make_pair(name, std::move(fontset))).second;
|
||||
return fontsets_.emplace(name, std::move(fontset)).second;
|
||||
}
|
||||
|
||||
boost::optional<font_set const&> Map::find_fontset(std::string const& name) const
|
||||
|
|
|
@ -48,7 +48,7 @@ bool mapped_memory_cache::insert(std::string const& uri, mapped_region_ptr mem)
|
|||
#ifdef MAPNIK_THREADSAFE
|
||||
mapnik::scoped_lock lock(mutex_);
|
||||
#endif
|
||||
return cache_.insert(std::make_pair(uri,mem)).second;
|
||||
return cache_.emplace(uri,mem).second;
|
||||
}
|
||||
|
||||
boost::optional<mapped_region_ptr> mapped_memory_cache::find(std::string const& uri, bool update_cache)
|
||||
|
@ -71,12 +71,10 @@ boost::optional<mapped_region_ptr> mapped_memory_cache::find(std::string const&
|
|||
{
|
||||
boost::interprocess::file_mapping mapping(uri.c_str(),boost::interprocess::read_only);
|
||||
mapped_region_ptr region(std::make_shared<boost::interprocess::mapped_region>(mapping,boost::interprocess::read_only));
|
||||
|
||||
result.reset(region);
|
||||
|
||||
if (update_cache)
|
||||
{
|
||||
cache_.insert(std::make_pair(uri,*result));
|
||||
cache_.emplace(uri,*result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ marker_cache::marker_cache()
|
|||
boost::optional<mapnik::image_ptr> bitmap_data = boost::optional<mapnik::image_ptr>(std::make_shared<image_data_32>(4,4));
|
||||
(*bitmap_data)->set(0xff000000);
|
||||
marker_ptr mark = std::make_shared<mapnik::marker>(bitmap_data);
|
||||
marker_cache_.insert(std::make_pair("image://square",mark));
|
||||
marker_cache_.emplace("image://square",mark);
|
||||
}
|
||||
|
||||
marker_cache::~marker_cache() {}
|
||||
|
@ -103,7 +103,7 @@ bool marker_cache::insert_svg(std::string const& name, std::string const& svg_st
|
|||
iterator_type itr = svg_cache_.find(key);
|
||||
if (itr == svg_cache_.end())
|
||||
{
|
||||
return svg_cache_.insert(std::make_pair(key,svg_string)).second;
|
||||
return svg_cache_.emplace(key,svg_string).second;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ bool marker_cache::insert_marker(std::string const& uri, marker_ptr path)
|
|||
#ifdef MAPNIK_THREADSAFE
|
||||
mapnik::scoped_lock lock(mutex_);
|
||||
#endif
|
||||
return marker_cache_.insert(std::make_pair(uri,path)).second;
|
||||
return marker_cache_.emplace(uri,path).second;
|
||||
}
|
||||
|
||||
boost::optional<marker_ptr> marker_cache::find(std::string const& uri,
|
||||
|
@ -165,7 +165,7 @@ boost::optional<marker_ptr> marker_cache::find(std::string const& uri,
|
|||
result.reset(mark);
|
||||
if (update_cache)
|
||||
{
|
||||
marker_cache_.insert(std::make_pair(uri,*result));
|
||||
marker_cache_.emplace(uri,*result);
|
||||
}
|
||||
}
|
||||
// otherwise assume file-based
|
||||
|
@ -194,7 +194,7 @@ boost::optional<marker_ptr> marker_cache::find(std::string const& uri,
|
|||
result.reset(mark);
|
||||
if (update_cache)
|
||||
{
|
||||
marker_cache_.insert(std::make_pair(uri,*result));
|
||||
marker_cache_.emplace(uri,*result);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -218,7 +218,7 @@ boost::optional<marker_ptr> marker_cache::find(std::string const& uri,
|
|||
result.reset(mark);
|
||||
if (update_cache)
|
||||
{
|
||||
marker_cache_.insert(std::make_pair(uri,*result));
|
||||
marker_cache_.emplace(uri,*result);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -94,7 +94,7 @@ bool font_face::glyph_dimensions(glyph_info & glyph) const
|
|||
glyph.unscaled_ymax = glyph_bbox.yMax;
|
||||
glyph.unscaled_advance = face_->glyph->advance.x;
|
||||
glyph.unscaled_line_height = face_->size->metrics.height;
|
||||
glyph_info_cache_.insert(std::make_pair(glyph.glyph_index, glyph));
|
||||
glyph_info_cache_.emplace(glyph.glyph_index, glyph);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ void registry::register_name(std::string const& name, from_xml_function_ptr ptr,
|
|||
if (overwrite) {
|
||||
map_[name] = ptr;
|
||||
} else {
|
||||
map_.insert(make_pair(name, ptr));
|
||||
map_.emplace(name, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ void registry::register_name(std::string name, from_xml_function_ptr ptr, bool o
|
|||
if (overwrite) {
|
||||
map_[name] = ptr;
|
||||
} else {
|
||||
map_.insert(make_pair(name, ptr));
|
||||
map_.emplace(name, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ xml_node &xml_node::add_child(std::string && name, unsigned line, bool is_text)
|
|||
|
||||
void xml_node::add_attribute(const char * name, const char * value)
|
||||
{
|
||||
attributes_.insert(std::make_pair(name,xml_attribute(value)));
|
||||
attributes_.emplace(name,xml_attribute(value));
|
||||
}
|
||||
|
||||
xml_node::attribute_map const& xml_node::get_attributes() const
|
||||
|
|
Loading…
Add table
Reference in a new issue