| Index: compiled/filter/Filter.cpp |
| =================================================================== |
| --- a/compiled/filter/Filter.cpp |
| +++ b/compiled/filter/Filter.cpp |
| @@ -73,16 +73,22 @@ |
| } |
| Filter::Filter(Type type, const String& text) |
| : mText(text), mType(type) |
| { |
| annotate_address(this, "Filter"); |
| } |
| +Filter::Filter(Type type, String&& text) |
| + : mText(text), mType(type) |
| +{ |
| + annotate_address(this, "Filter"); |
| +} |
| + |
| Filter::~Filter() |
| { |
| knownFilters.erase(mText); |
| } |
| OwnedString Filter::Serialize() const |
| { |
| OwnedString result(u"[Filter]\ntext="_str); |
| @@ -145,17 +151,20 @@ |
| if (static_cast<ElemHideEmulationFilter*>(filter.get())->IsGeneric()) |
| filter = FilterPtr(new InvalidFilter(text, u"filter_elemhideemulation_nodomain"_str), false); |
| break; |
| default: |
| // This should never happen but just in case |
| return nullptr; |
| } |
| - // This is a hack: we looked up the entry using text but create it using |
| - // filter->mText. This works because both are equal at this point. However, |
| - // text refers to a temporary buffer which will go away. |
| enter_context("Adding to known filters"); |
| - knownFilter.assign(filter->mText, filter.get()); |
| + if (text != filter->mText) |
| + knownFilters[filter->mText] = filter.get(); |
| + else |
| + // This is a hack: we looked up the entry using text but create it using |
| + // filter->mText. This works because both are equal at this point. However, |
| + // text refers to a temporary buffer which will go away. |
| + knownFilter.assign(filter->mText, filter.get()); |
| exit_context(); |
| return filter.release(); |
| } |