Skip to content

Commit

Permalink
don't always copy the underlying config on side filters
Browse files Browse the repository at this point in the history
I checked all codes that construct side filters but i couldn't find a
single occurance where the side filter object lived longer than the
underlying config object. (there were occurances in
terrain_filter/side_filer where i was not sure so i added an extra
make_safe there). Feels a littlte strange since there should've been a
reason why that make_safe call was added in the first place.
  • Loading branch information
gfgtdf committed Aug 27, 2017
1 parent dac7829 commit 31bb0ec
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/side_filter.cpp
Expand Up @@ -124,7 +124,7 @@ bool side_filter::match_internal(const team &t) const
if(cfg_.has_child("has_unit")) {
const vconfig & ufilt_cfg = cfg_.child("has_unit");
if (!ufilter_) {
ufilter_.reset(new unit_filter(ufilt_cfg, fc_));
ufilter_.reset(new unit_filter(ufilt_cfg.make_safe(), fc_));
ufilter_->set_use_flat_tod(flat_);
}
bool found = false;
Expand Down
2 changes: 1 addition & 1 deletion src/terrain/filter.cpp
Expand Up @@ -166,7 +166,7 @@ bool terrain_filter::match_internal(const map_location& loc, const unit* ref_uni
if (!u.valid())
return false;
if (!cache_.ufilter_) {
cache_.ufilter_.reset(new unit_filter(cfg_.child("filter"), fc_));
cache_.ufilter_.reset(new unit_filter(cfg_.child("filter").make_safe(), fc_));
cache_.ufilter_->set_use_flat_tod(flat_);
}
if (!cache_.ufilter_->matches(*u, loc))
Expand Down
1 change: 0 additions & 1 deletion src/units/filter.hpp
Expand Up @@ -98,7 +98,6 @@ class unit_filter
, impl_(cfg_)
, max_matches_(-1)
{
cfg_.make_safe();
}

unit_filter(const unit_filter&) = default;
Expand Down

0 comments on commit 31bb0ec

Please sign in to comment.