Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/FilterEngine.cpp

Issue 29334678: Issue 3589 - Change return type of AdblockPlus::JsValue::Call from pointer to r-value object. (Closed)
Patch Set: Created Jan. 27, 2016, 11:17 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/AdblockPlus/JsValue.h ('k') | src/JsValue.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/FilterEngine.cpp
diff --git a/src/FilterEngine.cpp b/src/FilterEngine.cpp
index eb515e2789ed61ec03d7aff687c1a8a3be3a6942..20a0f1759b159d663bef2f42dfd25bed81674654 100644
--- a/src/FilterEngine.cpp
+++ b/src/FilterEngine.cpp
@@ -57,7 +57,7 @@ bool Filter::IsListed()
JsValuePtr func = jsEngine->Evaluate("API.isListedFilter");
JsValueList params;
params.push_back(shared_from_this());
- return func->Call(params)->AsBool();
+ return func->Call(params).AsBool();
}
void Filter::AddToList()
@@ -93,7 +93,7 @@ bool Subscription::IsListed()
JsValuePtr func = jsEngine->Evaluate("API.isListedSubscription");
JsValueList params;
params.push_back(shared_from_this());
- return func->Call(params)->AsBool();
+ return func->Call(params).AsBool();
}
void Subscription::AddToList()
@@ -125,8 +125,8 @@ bool Subscription::IsUpdating()
JsValuePtr func = jsEngine->Evaluate("API.isSubscriptionUpdating");
JsValueList params;
params.push_back(shared_from_this());
- JsValuePtr result = func->Call(params);
- return result->AsBool();
+ JsValue result = func->Call(params);
+ return result.AsBool();
}
bool Subscription::operator==(const Subscription& subscription) const
@@ -227,7 +227,7 @@ FilterPtr FilterEngine::GetFilter(const std::string& text)
JsValuePtr func = jsEngine->Evaluate("API.getFilterFromText");
JsValueList params;
params.push_back(jsEngine->NewValue(text));
- return FilterPtr(new Filter(std::move(*func->Call(params))));
+ return FilterPtr(new Filter(func->Call(params)));
}
SubscriptionPtr FilterEngine::GetSubscription(const std::string& url)
@@ -235,13 +235,13 @@ SubscriptionPtr FilterEngine::GetSubscription(const std::string& url)
JsValuePtr func = jsEngine->Evaluate("API.getSubscriptionFromUrl");
JsValueList params;
params.push_back(jsEngine->NewValue(url));
- return SubscriptionPtr(new Subscription(std::move(*func->Call(params))));
+ return SubscriptionPtr(new Subscription(func->Call(params)));
}
std::vector<FilterPtr> FilterEngine::GetListedFilters() const
{
JsValuePtr func = jsEngine->Evaluate("API.getListedFilters");
- JsValueList values = func->Call()->AsList();
+ JsValueList values = func->Call().AsList();
std::vector<FilterPtr> result;
for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
result.push_back(FilterPtr(new Filter(std::move(**it))));
@@ -251,7 +251,7 @@ std::vector<FilterPtr> FilterEngine::GetListedFilters() const
std::vector<SubscriptionPtr> FilterEngine::GetListedSubscriptions() const
{
JsValuePtr func = jsEngine->Evaluate("API.getListedSubscriptions");
- JsValueList values = func->Call()->AsList();
+ JsValueList values = func->Call().AsList();
std::vector<SubscriptionPtr> result;
for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
result.push_back(SubscriptionPtr(new Subscription(std::move(**it))));
@@ -261,7 +261,7 @@ std::vector<SubscriptionPtr> FilterEngine::GetListedSubscriptions() const
std::vector<SubscriptionPtr> FilterEngine::FetchAvailableSubscriptions() const
{
JsValuePtr func = jsEngine->Evaluate("API.getRecommendedSubscriptions");
- JsValueList values = func->Call()->AsList();
+ JsValueList values = func->Call().AsList();
std::vector<SubscriptionPtr> result;
for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
result.push_back(SubscriptionPtr(new Subscription(std::move(**it))));
@@ -346,9 +346,9 @@ AdblockPlus::FilterPtr FilterEngine::CheckFilterMatch(const std::string& url,
params.push_back(jsEngine->NewValue(url));
params.push_back(jsEngine->NewValue(ContentTypeToString(contentType)));
params.push_back(jsEngine->NewValue(documentUrl));
- JsValuePtr result = func->Call(params);
- if (!result->IsNull())
- return FilterPtr(new Filter(std::move(*result)));
+ JsValue result = func->Call(params);
+ if (!result.IsNull())
+ return FilterPtr(new Filter(std::move(result)));
else
return FilterPtr();
}
@@ -358,7 +358,7 @@ std::vector<std::string> FilterEngine::GetElementHidingSelectors(const std::stri
JsValuePtr func = jsEngine->Evaluate("API.getElementHidingSelectors");
JsValueList params;
params.push_back(jsEngine->NewValue(domain));
- JsValueList result = func->Call(params)->AsList();
+ JsValueList result = func->Call(params).AsList();
std::vector<std::string> selectors;
for (JsValueList::iterator it = result.begin(); it != result.end(); ++it)
selectors.push_back((*it)->AsString());
@@ -370,7 +370,7 @@ JsValuePtr FilterEngine::GetPref(const std::string& pref) const
JsValuePtr func = jsEngine->Evaluate("API.getPref");
JsValueList params;
params.push_back(jsEngine->NewValue(pref));
- return func->Call(params);
+ return std::make_shared<JsValue>(func->Call(params));
Oleksandr 2016/01/31 21:23:24 Nit: This reminds me - isn't it time to drop use o
Eric 2016/02/08 19:54:50 It's already been done in the libadblockplus repos
}
void FilterEngine::SetPref(const std::string& pref, JsValuePtr value)
@@ -387,7 +387,7 @@ std::string FilterEngine::GetHostFromURL(const std::string& url)
JsValuePtr func = jsEngine->Evaluate("API.getHostFromUrl");
JsValueList params;
params.push_back(jsEngine->NewValue(url));
- return func->Call(params)->AsString();
+ return func->Call(params).AsString();
}
void FilterEngine::SetUpdateAvailableCallback(
@@ -472,7 +472,7 @@ int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2)
params.push_back(jsEngine->NewValue(v1));
params.push_back(jsEngine->NewValue(v2));
JsValuePtr func = jsEngine->Evaluate("API.compareVersions");
- return func->Call(params)->AsInt();
+ return func->Call(params).AsInt();
}
FilterPtr FilterEngine::GetWhitelistingFilter(const std::string& url,
« no previous file with comments | « include/AdblockPlus/JsValue.h ('k') | src/JsValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld