Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(905)

Unified Diff: src/runtime/runtime-i18n.cc

Issue 2006673002: Reduce boilerplace for common pattern to return MaybeHandle. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase and fix Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime-function.cc ('k') | src/runtime/runtime-internal.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-i18n.cc
diff --git a/src/runtime/runtime-i18n.cc b/src/runtime/runtime-i18n.cc
index b6103cbb2ab94c30acbc32805d67e3e5a7235707..68bdd654453824f03cd5c22f33fd22074608933c 100644
--- a/src/runtime/runtime-i18n.cc
+++ b/src/runtime/runtime-i18n.cc
@@ -382,13 +382,10 @@ RUNTIME_FUNCTION(Runtime_InternalDateFormat) {
icu::UnicodeString result;
date_format->format(value->Number(), result);
- Handle<String> result_str;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result_str,
- isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
- reinterpret_cast<const uint16_t*>(result.getBuffer()),
- result.length())));
- return *result_str;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
+ reinterpret_cast<const uint16_t*>(result.getBuffer()),
+ result.length())));
}
@@ -410,12 +407,9 @@ RUNTIME_FUNCTION(Runtime_InternalDateParse) {
UDate date = date_format->parse(u_date, status);
if (U_FAILURE(status)) return isolate->heap()->undefined_value();
- Handle<JSDate> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- JSDate::New(isolate->date_function(), isolate->date_function(),
- static_cast<double>(date)));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, JSDate::New(isolate->date_function(), isolate->date_function(),
+ static_cast<double>(date)));
}
@@ -476,13 +470,10 @@ RUNTIME_FUNCTION(Runtime_InternalNumberFormat) {
icu::UnicodeString result;
number_format->format(value->Number(), result);
- Handle<String> result_str;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result_str,
- isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
- reinterpret_cast<const uint16_t*>(result.getBuffer()),
- result.length())));
- return *result_str;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
+ reinterpret_cast<const uint16_t*>(result.getBuffer()),
+ result.length())));
}
@@ -647,13 +638,10 @@ RUNTIME_FUNCTION(Runtime_StringNormalize) {
return isolate->heap()->undefined_value();
}
- Handle<String> result_str;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result_str,
- isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
- reinterpret_cast<const uint16_t*>(result.getBuffer()),
- result.length())));
- return *result_str;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
+ reinterpret_cast<const uint16_t*>(result.getBuffer()),
+ result.length())));
}
@@ -848,13 +836,11 @@ MUST_USE_RESULT Object* LocaleConvertCase(Handle<String> s, Isolate* isolate,
// If no change is made, just return |s|.
if (converted.getBuffer() == src) return *s;
}
- Handle<String> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
+ RETURN_RESULT_OR_FAILURE(
+ isolate,
isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
reinterpret_cast<const uint16_t*>(converted.getBuffer()),
converted.length())));
- return *result;
}
auto case_converter = is_to_upper ? u_strToUpper : u_strToLower;
« no previous file with comments | « src/runtime/runtime-function.cc ('k') | src/runtime/runtime-internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698