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

Unified Diff: lib/string.cc

Issue 10874072: Use the return value of vm native methods to set the return value, (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 4 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
Index: lib/string.cc
===================================================================
--- lib/string.cc (revision 11528)
+++ lib/string.cc (working copy)
@@ -41,15 +41,13 @@
}
temp[i] = value;
}
- String& result = String::Handle(isolate);
if (is_one_byte_string) {
- result ^= OneByteString::New(temp, len, Heap::kNew);
+ return OneByteString::New(temp, len, Heap::kNew);
} else if (is_two_byte_string) {
- result ^= TwoByteString::New(temp, len, Heap::kNew);
+ return TwoByteString::New(temp, len, Heap::kNew);
} else {
- result ^= FourByteString::New(temp, len, Heap::kNew);
+ return FourByteString::New(temp, len, Heap::kNew);
}
- arguments->SetReturn(result);
}
@@ -60,10 +58,7 @@
intptr_t start = start_obj.Value();
intptr_t end = end_obj.Value();
-
- const String& result = String::Handle(
- isolate, String::SubString(receiver, start, (end - start)));
- arguments->SetReturn(result);
+ return String::SubString(receiver, start, (end - start));
}
@@ -72,14 +67,13 @@
intptr_t hash_val = receiver.Hash();
ASSERT(hash_val > 0);
ASSERT(Smi::IsValid(hash_val));
- const Smi& hash_smi = Smi::Handle(Smi::New(hash_val));
- arguments->SetReturn(hash_smi);
+ return Smi::New(hash_val);
}
DEFINE_NATIVE_ENTRY(String_getLength, 1) {
const String& receiver = String::CheckedHandle(arguments->At(0));
- arguments->SetReturn(Smi::Handle(Smi::New(receiver.Length())));
+ return Smi::New(receiver.Length());
}
@@ -109,7 +103,7 @@
GET_NATIVE_ARGUMENT(Integer, index, arguments->At(1));
uint32_t value = StringValueAt(receiver, index);
ASSERT(value <= 0x10FFFF);
- arguments->SetReturn(String::Handle(Symbols::New(&value, 1)));
+ return Symbols::New(&value, 1);
}
DEFINE_NATIVE_ENTRY(String_charCodeAt, 2) {
@@ -118,31 +112,28 @@
int32_t value = StringValueAt(receiver, index);
ASSERT(value >= 0);
ASSERT(value <= 0x10FFFF);
- arguments->SetReturn(Smi::Handle(Smi::New(value)));
+ return Smi::New(value);
}
DEFINE_NATIVE_ENTRY(String_concat, 2) {
const String& receiver = String::CheckedHandle(arguments->At(0));
GET_NATIVE_ARGUMENT(String, b, arguments->At(1));
- const String& result = String::Handle(String::Concat(receiver, b));
- arguments->SetReturn(result);
+ return String::Concat(receiver, b);
}
DEFINE_NATIVE_ENTRY(String_toLowerCase, 1) {
const String& receiver = String::CheckedHandle(arguments->At(0));
ASSERT(!receiver.IsNull());
- const String& result = String::Handle(String::ToLowerCase(receiver));
- arguments->SetReturn(result);
+ return String::ToLowerCase(receiver);
}
DEFINE_NATIVE_ENTRY(String_toUpperCase, 1) {
const String& receiver = String::CheckedHandle(arguments->At(0));
ASSERT(!receiver.IsNull());
- const String& result = String::Handle(String::ToUpperCase(receiver));
- arguments->SetReturn(result);
+ return String::ToUpperCase(receiver);
}
@@ -163,8 +154,7 @@
Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
}
}
- const String& result = String::Handle(String::ConcatAll(strings));
- arguments->SetReturn(result);
+ return String::ConcatAll(strings);
}
} // namespace dart
« no previous file with comments | « lib/stopwatch.cc ('k') | lib/weak_property.cc » ('j') | vm/bootstrap_natives.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698