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

Unified Diff: src/natives-external.cc

Issue 795383003: Don't use AddSubstring for external natives (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 6 years 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/utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/natives-external.cc
diff --git a/src/natives-external.cc b/src/natives-external.cc
index 138abe1e5ca8258853162382d7f3e31d5484a063..e601808fe8182055683d32133081b36e46c9938f 100644
--- a/src/natives-external.cc
+++ b/src/natives-external.cc
@@ -82,15 +82,14 @@ class NativesStore {
NativesStore() : debugger_count_(0) {}
Vector<const char> NameFromId(const byte* id, int id_length) {
- Vector<char> name(Vector<char>::New(id_length + 11));
- SimpleStringBuilder builder(name.start(), name.length());
- builder.AddString("native ");
- builder.AddSubstring(reinterpret_cast<const char*>(id), id_length);
- builder.AddString(".js");
- builder.Finalize();
- // SimpleStringBuilder wants zero-byte; the caller does not.
- DCHECK(name[name.length() - 1] == '\0');
- name.Truncate(name.length() - 1);
+ const char native[] = "native ";
Sven Panne 2014/12/18 10:32:32 Probably not a big deal here, but note that GCC ac
+ const char extension[] = ".js";
+ Vector<char> name(Vector<char>::New(id_length + sizeof(native) - 1 +
+ sizeof(extension) - 1));
+ memcpy(name.start(), native, sizeof(native) - 1);
+ memcpy(name.start() + sizeof(native) - 1, id, id_length);
+ memcpy(name.start() + sizeof(native) - 1 + id_length, extension,
+ sizeof(extension) - 1);
return Vector<const char>::cast(name);
}
« no previous file with comments | « no previous file | src/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698