Commit 1292e8c8 authored by Florian Sattler's avatar Florian Sattler Committed by Commit Bot

[cleanup] Fix objects classes, removing unnecessary copies.

Fixing clang-tidy warning.

Bug: v8:8015
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: I722e15193b3b269e94dc8e5aba80f6f73c95cda8
Reviewed-on: https://chromium-review.googlesource.com/1228036
Commit-Queue: Florian Sattler <sattlerf@google.com>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56109}
parent 9850ffad
...@@ -1221,15 +1221,15 @@ std::unique_ptr<icu::RegexMatcher> GetAnyExtensionRegexpMatcher() { ...@@ -1221,15 +1221,15 @@ std::unique_ptr<icu::RegexMatcher> GetAnyExtensionRegexpMatcher() {
// ECMA 402 9.2.7 LookupSupportedLocales(availableLocales, requestedLocales) // ECMA 402 9.2.7 LookupSupportedLocales(availableLocales, requestedLocales)
// https://tc39.github.io/ecma402/#sec-lookupsupportedlocales // https://tc39.github.io/ecma402/#sec-lookupsupportedlocales
std::vector<std::string> LookupSupportedLocales( std::vector<std::string> LookupSupportedLocales(
std::set<std::string> available_locales, const std::set<std::string>& available_locales,
std::vector<std::string> requested_locales) { const std::vector<std::string>& requested_locales) {
std::unique_ptr<icu::RegexMatcher> matcher = GetAnyExtensionRegexpMatcher(); std::unique_ptr<icu::RegexMatcher> matcher = GetAnyExtensionRegexpMatcher();
// 1. Let subset be a new empty List. // 1. Let subset be a new empty List.
std::vector<std::string> subset; std::vector<std::string> subset;
// 2. For each element locale of requestedLocales in List order, do // 2. For each element locale of requestedLocales in List order, do
for (auto locale : requested_locales) { for (const auto& locale : requested_locales) {
// 2.a. Let noExtensionsLocale be the String value that is locale with all // 2.a. Let noExtensionsLocale be the String value that is locale with all
// Unicode locale extension sequences removed. // Unicode locale extension sequences removed.
icu::UnicodeString locale_uni(locale.c_str(), -1, US_INV); icu::UnicodeString locale_uni(locale.c_str(), -1, US_INV);
...@@ -1276,8 +1276,8 @@ std::vector<std::string> LookupSupportedLocales( ...@@ -1276,8 +1276,8 @@ std::vector<std::string> LookupSupportedLocales(
// ECMA 402 9.2.8 BestFitSupportedLocales(availableLocales, requestedLocales) // ECMA 402 9.2.8 BestFitSupportedLocales(availableLocales, requestedLocales)
// https://tc39.github.io/ecma402/#sec-bestfitsupportedlocales // https://tc39.github.io/ecma402/#sec-bestfitsupportedlocales
std::vector<std::string> BestFitSupportedLocales( std::vector<std::string> BestFitSupportedLocales(
std::set<std::string> available_locales, const std::set<std::string>& available_locales,
std::vector<std::string> requested_locales) { const std::vector<std::string>& requested_locales) {
return LookupSupportedLocales(available_locales, requested_locales); return LookupSupportedLocales(available_locales, requested_locales);
} }
...@@ -1324,9 +1324,9 @@ MaybeHandle<JSObject> CreateReadOnlyArray(Isolate* isolate, ...@@ -1324,9 +1324,9 @@ MaybeHandle<JSObject> CreateReadOnlyArray(Isolate* isolate,
// ECMA 402 9.2.9 SupportedLocales(availableLocales, requestedLocales, options) // ECMA 402 9.2.9 SupportedLocales(availableLocales, requestedLocales, options)
// https://tc39.github.io/ecma402/#sec-supportedlocales // https://tc39.github.io/ecma402/#sec-supportedlocales
MaybeHandle<JSObject> SupportedLocales( MaybeHandle<JSObject> SupportedLocales(
Isolate* isolate, std::string service, Isolate* isolate, const std::string& service,
std::set<std::string> available_locales, const std::set<std::string>& available_locales,
std::vector<std::string> requested_locales, Handle<Object> options) { const std::vector<std::string>& requested_locales, Handle<Object> options) {
std::vector<std::string> supported_locales; std::vector<std::string> supported_locales;
// 1. If options is not undefined, then // 1. If options is not undefined, then
......
...@@ -32,7 +32,7 @@ namespace { ...@@ -32,7 +32,7 @@ namespace {
class PatternMap { class PatternMap {
public: public:
PatternMap(std::string pattern, std::string value) PatternMap(std::string pattern, std::string value)
: pattern(pattern), value(value) {} : pattern(std::move(pattern)), value(std::move(value)) {}
virtual ~PatternMap() = default; virtual ~PatternMap() = default;
std::string pattern; std::string pattern;
std::string value; std::string value;
...@@ -42,7 +42,9 @@ class PatternItem { ...@@ -42,7 +42,9 @@ class PatternItem {
public: public:
PatternItem(const std::string property, std::vector<PatternMap> pairs, PatternItem(const std::string property, std::vector<PatternMap> pairs,
std::vector<const char*>* allowed_values) std::vector<const char*>* allowed_values)
: property(property), pairs(pairs), allowed_values(allowed_values) {} : property(std::move(property)),
pairs(std::move(pairs)),
allowed_values(allowed_values) {}
virtual ~PatternItem() = default; virtual ~PatternItem() = default;
const std::string property; const std::string property;
...@@ -102,7 +104,7 @@ class PatternData { ...@@ -102,7 +104,7 @@ class PatternData {
public: public:
PatternData(const std::string property, std::vector<PatternMap> pairs, PatternData(const std::string property, std::vector<PatternMap> pairs,
std::vector<const char*>* allowed_values) std::vector<const char*>* allowed_values)
: property(property), allowed_values(allowed_values) { : property(std::move(property)), allowed_values(allowed_values) {
for (const auto& pair : pairs) { for (const auto& pair : pairs) {
map.insert(std::make_pair(pair.value, pair.pattern)); map.insert(std::make_pair(pair.value, pair.pattern));
} }
...@@ -180,12 +182,12 @@ void SetPropertyFromPattern(Isolate* isolate, const std::string& pattern, ...@@ -180,12 +182,12 @@ void SetPropertyFromPattern(Isolate* isolate, const std::string& pattern,
// ii. If hc is "h11" or "h12", let v be true. // ii. If hc is "h11" or "h12", let v be true.
// iii. Else if, hc is "h23" or "h24", let v be false. // iii. Else if, hc is "h23" or "h24", let v be false.
// iv. Else, let v be undefined. // iv. Else, let v be undefined.
if (pattern.find("h") != std::string::npos) { if (pattern.find('h') != std::string::npos) {
CHECK(JSReceiver::CreateDataProperty( CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->NewStringFromStaticChars("hour12"), isolate, options, factory->NewStringFromStaticChars("hour12"),
factory->true_value(), kDontThrow) factory->true_value(), kDontThrow)
.FromJust()); .FromJust());
} else if (pattern.find("H") != std::string::npos) { } else if (pattern.find('H') != std::string::npos) {
CHECK(JSReceiver::CreateDataProperty( CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->NewStringFromStaticChars("hour12"), isolate, options, factory->NewStringFromStaticChars("hour12"),
factory->false_value(), kDontThrow) factory->false_value(), kDontThrow)
...@@ -702,7 +704,7 @@ std::unique_ptr<icu::Calendar> CreateCalendar(Isolate* isolate, ...@@ -702,7 +704,7 @@ std::unique_ptr<icu::Calendar> CreateCalendar(Isolate* isolate,
std::unique_ptr<icu::SimpleDateFormat> CreateICUDateFormat( std::unique_ptr<icu::SimpleDateFormat> CreateICUDateFormat(
Isolate* isolate, const icu::Locale& icu_locale, Isolate* isolate, const icu::Locale& icu_locale,
const std::string skeleton) { const std::string& skeleton) {
// See https://github.com/tc39/ecma402/issues/225 . The best pattern // See https://github.com/tc39/ecma402/issues/225 . The best pattern
// generation needs to be done in the base locale according to the // generation needs to be done in the base locale according to the
// current spec however odd it may be. See also crbug.com/826549 . // current spec however odd it may be. See also crbug.com/826549 .
......
...@@ -238,8 +238,8 @@ Handle<String> UnitAsString(Isolate* isolate, URelativeDateTimeUnit unit_enum) { ...@@ -238,8 +238,8 @@ Handle<String> UnitAsString(Isolate* isolate, URelativeDateTimeUnit unit_enum) {
} }
MaybeHandle<JSArray> GenerateRelativeTimeFormatParts( MaybeHandle<JSArray> GenerateRelativeTimeFormatParts(
Isolate* isolate, icu::UnicodeString formatted, Isolate* isolate, const icu::UnicodeString& formatted,
icu::UnicodeString integer_part, URelativeDateTimeUnit unit_enum) { const icu::UnicodeString& integer_part, URelativeDateTimeUnit unit_enum) {
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
Handle<JSArray> array = factory->NewJSArray(0); Handle<JSArray> array = factory->NewJSArray(0);
int32_t found = formatted.indexOf(integer_part); int32_t found = formatted.indexOf(integer_part);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment