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() {
// ECMA 402 9.2.7 LookupSupportedLocales(availableLocales, requestedLocales)
// https://tc39.github.io/ecma402/#sec-lookupsupportedlocales
std::vector<std::string> LookupSupportedLocales(
std::set<std::string> available_locales,
std::vector<std::string> requested_locales) {
const std::set<std::string>& available_locales,
const std::vector<std::string>& requested_locales) {
std::unique_ptr<icu::RegexMatcher> matcher = GetAnyExtensionRegexpMatcher();
// 1. Let subset be a new empty List.
std::vector<std::string> subset;
// 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
// Unicode locale extension sequences removed.
icu::UnicodeString locale_uni(locale.c_str(), -1, US_INV);
......@@ -1276,8 +1276,8 @@ std::vector<std::string> LookupSupportedLocales(
// ECMA 402 9.2.8 BestFitSupportedLocales(availableLocales, requestedLocales)
// https://tc39.github.io/ecma402/#sec-bestfitsupportedlocales
std::vector<std::string> BestFitSupportedLocales(
std::set<std::string> available_locales,
std::vector<std::string> requested_locales) {
const std::set<std::string>& available_locales,
const std::vector<std::string>& requested_locales) {
return LookupSupportedLocales(available_locales, requested_locales);
}
......@@ -1324,9 +1324,9 @@ MaybeHandle<JSObject> CreateReadOnlyArray(Isolate* isolate,
// ECMA 402 9.2.9 SupportedLocales(availableLocales, requestedLocales, options)
// https://tc39.github.io/ecma402/#sec-supportedlocales
MaybeHandle<JSObject> SupportedLocales(
Isolate* isolate, std::string service,
std::set<std::string> available_locales,
std::vector<std::string> requested_locales, Handle<Object> options) {
Isolate* isolate, const std::string& service,
const std::set<std::string>& available_locales,
const std::vector<std::string>& requested_locales, Handle<Object> options) {
std::vector<std::string> supported_locales;
// 1. If options is not undefined, then
......
......@@ -32,7 +32,7 @@ namespace {
class PatternMap {
public:
PatternMap(std::string pattern, std::string value)
: pattern(pattern), value(value) {}
: pattern(std::move(pattern)), value(std::move(value)) {}
virtual ~PatternMap() = default;
std::string pattern;
std::string value;
......@@ -42,7 +42,9 @@ class PatternItem {
public:
PatternItem(const std::string property, std::vector<PatternMap> pairs,
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;
const std::string property;
......@@ -102,7 +104,7 @@ class PatternData {
public:
PatternData(const std::string property, std::vector<PatternMap> pairs,
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) {
map.insert(std::make_pair(pair.value, pair.pattern));
}
......@@ -180,12 +182,12 @@ void SetPropertyFromPattern(Isolate* isolate, const std::string& pattern,
// ii. If hc is "h11" or "h12", let v be true.
// iii. Else if, hc is "h23" or "h24", let v be false.
// iv. Else, let v be undefined.
if (pattern.find("h") != std::string::npos) {
if (pattern.find('h') != std::string::npos) {
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->NewStringFromStaticChars("hour12"),
factory->true_value(), kDontThrow)
.FromJust());
} else if (pattern.find("H") != std::string::npos) {
} else if (pattern.find('H') != std::string::npos) {
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->NewStringFromStaticChars("hour12"),
factory->false_value(), kDontThrow)
......@@ -702,7 +704,7 @@ std::unique_ptr<icu::Calendar> CreateCalendar(Isolate* isolate,
std::unique_ptr<icu::SimpleDateFormat> CreateICUDateFormat(
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
// generation needs to be done in the base locale according to the
// current spec however odd it may be. See also crbug.com/826549 .
......
......@@ -238,8 +238,8 @@ Handle<String> UnitAsString(Isolate* isolate, URelativeDateTimeUnit unit_enum) {
}
MaybeHandle<JSArray> GenerateRelativeTimeFormatParts(
Isolate* isolate, icu::UnicodeString formatted,
icu::UnicodeString integer_part, URelativeDateTimeUnit unit_enum) {
Isolate* isolate, const icu::UnicodeString& formatted,
const icu::UnicodeString& integer_part, URelativeDateTimeUnit unit_enum) {
Factory* factory = isolate->factory();
Handle<JSArray> array = factory->NewJSArray(0);
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