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

Unified Diff: src/profile-generator.cc

Issue 2769001: Factor out StringsStorage from CpuProfilesCollection. (Closed)
Patch Set: Comments addressed Created 10 years, 6 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 | « src/profile-generator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/profile-generator.cc
diff --git a/src/profile-generator.cc b/src/profile-generator.cc
index fb89a221aa5d2cd2e8e93ef1dedf69f14c56cfb5..44163a056863f080c9a2b8d5d67977399d4c1821 100644
--- a/src/profile-generator.cc
+++ b/src/profile-generator.cc
@@ -86,6 +86,37 @@ void TokenEnumerator::TokenRemoved(Object** token_location) {
}
+StringsStorage::StringsStorage()
+ : names_(StringsMatch) {
+}
+
+
+StringsStorage::~StringsStorage() {
+ for (HashMap::Entry* p = names_.Start();
+ p != NULL;
+ p = names_.Next(p)) {
+ DeleteArray(reinterpret_cast<const char*>(p->value));
+ }
+}
+
+
+const char* StringsStorage::GetName(String* name) {
+ if (name->IsString()) {
+ char* c_name =
+ name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL).Detach();
+ HashMap::Entry* cache_entry = names_.Lookup(c_name, name->Hash(), true);
+ if (cache_entry->value == NULL) {
+ // New entry added.
+ cache_entry->value = c_name;
+ } else {
+ DeleteArray(c_name);
+ }
+ return reinterpret_cast<const char*>(cache_entry->value);
+ }
+ return "";
+}
+
+
const char* CodeEntry::kEmptyNamePrefix = "";
unsigned CodeEntry::next_call_uid_ = 1;
@@ -438,8 +469,7 @@ void CodeMap::Print() {
CpuProfilesCollection::CpuProfilesCollection()
- : function_and_resource_names_(StringsMatch),
- profiles_uids_(UidsMatch),
+ : profiles_uids_(UidsMatch),
current_profiles_semaphore_(OS::CreateSemaphore(1)) {
// Create list of unabridged profiles.
profiles_by_token_.Add(new List<CpuProfile*>());
@@ -470,11 +500,6 @@ CpuProfilesCollection::~CpuProfilesCollection() {
profiles_by_token_.Iterate(DeleteProfilesList);
code_entries_.Iterate(DeleteCodeEntry);
args_count_names_.Iterate(DeleteArgsCountName);
- for (HashMap::Entry* p = function_and_resource_names_.Start();
- p != NULL;
- p = function_and_resource_names_.Next(p)) {
- DeleteArray(reinterpret_cast<const char*>(p->value));
- }
}
@@ -666,27 +691,6 @@ CodeEntry* CpuProfilesCollection::NewCodeEntry(int security_token_id) {
}
-const char* CpuProfilesCollection::GetName(String* name) {
- if (name->IsString()) {
- char* c_name =
- name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL).Detach();
- HashMap::Entry* cache_entry =
- function_and_resource_names_.Lookup(c_name,
- name->Hash(),
- true);
- if (cache_entry->value == NULL) {
- // New entry added.
- cache_entry->value = c_name;
- } else {
- DeleteArray(c_name);
- }
- return reinterpret_cast<const char*>(cache_entry->value);
- } else {
- return "";
- }
-}
-
-
const char* CpuProfilesCollection::GetName(int args_count) {
ASSERT(args_count >= 0);
if (args_count_names_.length() <= args_count) {
« no previous file with comments | « src/profile-generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698