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

Unified Diff: src/api.cc

Issue 11958040: Remove some unnecessary use of templates. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 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/heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index f4a78256ac41417dbe0fa2635bd1dd351b1f610f..54b233c2f5ff9931fd94291b42e91efc4239ce2b 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -4181,43 +4181,41 @@ int String::WriteAscii(char* buffer,
template<typename CharType>
-struct WriteHelper {
- static inline int Write(const String* string,
- CharType* buffer,
- int start,
- int length,
- int options) {
- i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate();
- if (IsDeadCheck(isolate, "v8::String::Write()")) return 0;
- LOG_API(isolate, "String::Write");
- ENTER_V8(isolate);
- ASSERT(start >= 0 && length >= -1);
- i::Handle<i::String> str = Utils::OpenHandle(string);
- isolate->string_tracker()->RecordWrite(str);
- if (options & String::HINT_MANY_WRITES_EXPECTED) {
- // Flatten the string for efficiency. This applies whether we are
- // using StringCharacterStream or Get(i) to access the characters.
- FlattenString(str);
- }
- int end = start + length;
- if ((length == -1) || (length > str->length() - start) )
- end = str->length();
- if (end < 0) return 0;
- i::String::WriteToFlat(*str, buffer, start, end);
- if (!(options & String::NO_NULL_TERMINATION) &&
- (length == -1 || end - start < length)) {
- buffer[end - start] = '\0';
- }
- return end - start;
+static inline int WriteHelper(const String* string,
+ CharType* buffer,
+ int start,
+ int length,
+ int options) {
+ i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate();
+ if (IsDeadCheck(isolate, "v8::String::Write()")) return 0;
+ LOG_API(isolate, "String::Write");
+ ENTER_V8(isolate);
+ ASSERT(start >= 0 && length >= -1);
+ i::Handle<i::String> str = Utils::OpenHandle(string);
+ isolate->string_tracker()->RecordWrite(str);
+ if (options & String::HINT_MANY_WRITES_EXPECTED) {
+ // Flatten the string for efficiency. This applies whether we are
+ // using StringCharacterStream or Get(i) to access the characters.
+ FlattenString(str);
+ }
+ int end = start + length;
+ if ((length == -1) || (length > str->length() - start) )
+ end = str->length();
+ if (end < 0) return 0;
+ i::String::WriteToFlat(*str, buffer, start, end);
+ if (!(options & String::NO_NULL_TERMINATION) &&
+ (length == -1 || end - start < length)) {
+ buffer[end - start] = '\0';
}
-};
+ return end - start;
+}
int String::WriteOneByte(uint8_t* buffer,
int start,
int length,
int options) const {
- return WriteHelper<uint8_t>::Write(this, buffer, start, length, options);
+ return WriteHelper(this, buffer, start, length, options);
}
@@ -4225,7 +4223,7 @@ int String::Write(uint16_t* buffer,
int start,
int length,
int options) const {
- return WriteHelper<uint16_t>::Write(this, buffer, start, length, options);
+ return WriteHelper(this, buffer, start, length, options);
}
« no previous file with comments | « no previous file | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698