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

Unified Diff: runtime/vm/symbols.cc

Issue 1322973006: Symbols::NewFormatted and old space allocation. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address review comment Created 5 years, 3 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 | « runtime/vm/symbols.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/symbols.cc
diff --git a/runtime/vm/symbols.cc b/runtime/vm/symbols.cc
index 03e6c6867545916e622b4c554fb4a16cbc910749..c9cbcf3131e2ebbecdf4c9ca3b81e18c8be9e648 100644
--- a/runtime/vm/symbols.cc
+++ b/runtime/vm/symbols.cc
@@ -540,6 +540,31 @@ RawString* Symbols::New(const String& str, intptr_t begin_index, intptr_t len) {
}
+
+RawString* Symbols::NewFormatted(const char* format, ...) {
+ va_list args;
+ va_start(args, format);
+ RawString* result = NewFormattedV(format, args);
+ NoSafepointScope no_safepoint;
+ va_end(args);
+ return result;
+}
+
+
+RawString* Symbols::NewFormattedV(const char* format, va_list args) {
+ va_list args_copy;
+ va_copy(args_copy, args);
+ intptr_t len = OS::VSNPrint(NULL, 0, format, args_copy);
+ va_end(args_copy);
+
+ Zone* zone = Thread::Current()->zone();
+ char* buffer = zone->Alloc<char>(len + 1);
+ OS::VSNPrint(buffer, (len + 1), format, args);
+
+ return Symbols::New(buffer);
+}
+
+
RawString* Symbols::FromCharCode(int32_t char_code) {
if (char_code > kMaxOneCharCodeSymbol) {
return FromUTF32(&char_code, 1);
« no previous file with comments | « runtime/vm/symbols.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698