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

Unified Diff: src/FilterEngine.cpp

Issue 4949583905947648: Issue 1280 - Update v8, the second part (Closed)
Patch Set: Created Oct. 27, 2014, 10:01 p.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 | « src/FileSystemJsObject.cpp ('k') | src/GlobalJsObject.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/FilterEngine.cpp
===================================================================
--- a/src/FilterEngine.cpp
+++ b/src/FilterEngine.cpp
@@ -28,8 +28,8 @@
extern std::string jsSources[];
-Filter::Filter(JsValuePtr value)
- : JsValue(value)
+Filter::Filter(JsValue&& value)
+ : JsValue{std::move(value)}
{
if (!IsObject())
throw std::runtime_error("JavaScript value is not an object");
@@ -81,8 +81,8 @@
return GetProperty("text")->AsString() == filter.GetProperty("text")->AsString();
}
-Subscription::Subscription(JsValuePtr value)
- : JsValue(value)
+Subscription::Subscription(JsValue&& value)
+ : JsValue{std::move(value)}
{
if (!IsObject())
throw std::runtime_error("JavaScript value is not an object");
@@ -143,7 +143,7 @@
{
// Lock the JS engine while we are loading scripts, no timeouts should fire
// until we are done.
- const JsContext context(jsEngine);
+ const JsContext context{*jsEngine};
for (int i = 0; !jsSources[i].empty(); i += 2)
jsEngine->Evaluate(jsSources[i + 1], jsSources[i]);
}
@@ -215,7 +215,7 @@
JsValuePtr func = jsEngine->Evaluate("API.getFilterFromText");
JsValueList params;
params.push_back(jsEngine->NewValue(text));
- return FilterPtr(new Filter(func->Call(params)));
+ return std::make_shared<Filter>(std::move(*func->Call(params)));
}
SubscriptionPtr FilterEngine::GetSubscription(const std::string& url)
@@ -223,7 +223,7 @@
JsValuePtr func = jsEngine->Evaluate("API.getSubscriptionFromUrl");
JsValueList params;
params.push_back(jsEngine->NewValue(url));
- return SubscriptionPtr(new Subscription(func->Call(params)));
+ return std::make_shared<Subscription>(std::move(*func->Call(params)));
}
std::vector<FilterPtr> FilterEngine::GetListedFilters() const
@@ -231,8 +231,8 @@
JsValuePtr func = jsEngine->Evaluate("API.getListedFilters");
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(*it)));
+ for (auto& value : values)
+ result.emplace_back(std::make_shared<Filter>(std::move(*value)));
return result;
}
@@ -241,8 +241,8 @@
JsValuePtr func = jsEngine->Evaluate("API.getListedSubscriptions");
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(*it)));
+ for (auto& value : values)
+ result.emplace_back(std::make_shared<Subscription>(std::move(*value)));
return result;
}
@@ -251,8 +251,8 @@
JsValuePtr func = jsEngine->Evaluate("API.getRecommendedSubscriptions");
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(*it)));
+ for (auto& value : values)
+ result.emplace_back(std::make_shared<Subscription>(std::move(*value)));
return result;
}
@@ -298,7 +298,7 @@
params.push_back(jsEngine->NewValue(documentUrl));
JsValuePtr result = func->Call(params);
if (!result->IsNull())
- return FilterPtr(new Filter(result));
+ return std::make_shared<Filter>(std::move(*result));
else
return FilterPtr();
}
« no previous file with comments | « src/FileSystemJsObject.cpp ('k') | src/GlobalJsObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld