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

Unified Diff: src/builtins.cc

Issue 1916393002: Refactoring to use ArrayVector where applicable (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm-offset-table-2
Patch Set: also refactor src/builtins.cc Created 4 years, 8 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 | « no previous file | src/code-stubs-hydrogen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index 3579a5329b14506456a0cee89cd56a34000918d8..cb9d0521459873852c1054363f442b4aeebeed3b 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -3113,8 +3113,7 @@ BUILTIN(DateConstructor) {
HandleScope scope(isolate);
double const time_val = JSDate::CurrentTimeValue(isolate);
char buffer[128];
- Vector<char> str(buffer, arraysize(buffer));
- ToDateString(time_val, str, isolate->date_cache());
+ ToDateString(time_val, ArrayVector(buffer), isolate->date_cache());
Handle<String> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
@@ -3697,8 +3696,8 @@ BUILTIN(DatePrototypeToDateString) {
HandleScope scope(isolate);
CHECK_RECEIVER(JSDate, date, "Date.prototype.toDateString");
char buffer[128];
- Vector<char> str(buffer, arraysize(buffer));
- ToDateString(date->value()->Number(), str, isolate->date_cache(), kDateOnly);
+ ToDateString(date->value()->Number(), ArrayVector(buffer),
+ isolate->date_cache(), kDateOnly);
Handle<String> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
@@ -3721,18 +3720,17 @@ BUILTIN(DatePrototypeToISOString) {
isolate->date_cache()->BreakDownTime(time_ms, &year, &month, &day, &weekday,
&hour, &min, &sec, &ms);
char buffer[128];
- Vector<char> str(buffer, arraysize(buffer));
if (year >= 0 && year <= 9999) {
- SNPrintF(str, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", year, month + 1, day,
- hour, min, sec, ms);
+ SNPrintF(ArrayVector(buffer), "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", year,
+ month + 1, day, hour, min, sec, ms);
} else if (year < 0) {
- SNPrintF(str, "-%06d-%02d-%02dT%02d:%02d:%02d.%03dZ", -year, month + 1, day,
- hour, min, sec, ms);
+ SNPrintF(ArrayVector(buffer), "-%06d-%02d-%02dT%02d:%02d:%02d.%03dZ", -year,
+ month + 1, day, hour, min, sec, ms);
} else {
- SNPrintF(str, "+%06d-%02d-%02dT%02d:%02d:%02d.%03dZ", year, month + 1, day,
- hour, min, sec, ms);
+ SNPrintF(ArrayVector(buffer), "+%06d-%02d-%02dT%02d:%02d:%02d.%03dZ", year,
+ month + 1, day, hour, min, sec, ms);
}
- return *isolate->factory()->NewStringFromAsciiChecked(str.start());
+ return *isolate->factory()->NewStringFromAsciiChecked(buffer);
}
@@ -3741,8 +3739,8 @@ BUILTIN(DatePrototypeToString) {
HandleScope scope(isolate);
CHECK_RECEIVER(JSDate, date, "Date.prototype.toString");
char buffer[128];
- Vector<char> str(buffer, arraysize(buffer));
- ToDateString(date->value()->Number(), str, isolate->date_cache());
+ ToDateString(date->value()->Number(), ArrayVector(buffer),
+ isolate->date_cache());
Handle<String> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
@@ -3756,8 +3754,8 @@ BUILTIN(DatePrototypeToTimeString) {
HandleScope scope(isolate);
CHECK_RECEIVER(JSDate, date, "Date.prototype.toTimeString");
char buffer[128];
- Vector<char> str(buffer, arraysize(buffer));
- ToDateString(date->value()->Number(), str, isolate->date_cache(), kTimeOnly);
+ ToDateString(date->value()->Number(), ArrayVector(buffer),
+ isolate->date_cache(), kTimeOnly);
Handle<String> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
@@ -3775,14 +3773,14 @@ BUILTIN(DatePrototypeToUTCString) {
return *isolate->factory()->NewStringFromAsciiChecked("Invalid Date");
}
char buffer[128];
- Vector<char> str(buffer, arraysize(buffer));
int64_t time_ms = static_cast<int64_t>(time_val);
int year, month, day, weekday, hour, min, sec, ms;
isolate->date_cache()->BreakDownTime(time_ms, &year, &month, &day, &weekday,
&hour, &min, &sec, &ms);
- SNPrintF(str, "%s, %02d %s %4d %02d:%02d:%02d GMT", kShortWeekDays[weekday],
- day, kShortMonths[month], year, hour, min, sec);
- return *isolate->factory()->NewStringFromAsciiChecked(str.start());
+ SNPrintF(ArrayVector(buffer), "%s, %02d %s %4d %02d:%02d:%02d GMT",
+ kShortWeekDays[weekday], day, kShortMonths[month], year, hour, min,
+ sec);
+ return *isolate->factory()->NewStringFromAsciiChecked(buffer);
}
« no previous file with comments | « no previous file | src/code-stubs-hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698