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

Unified Diff: src/d8.cc

Issue 42559: Remove stl dependencies from d8. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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/d8.h ('k') | src/date-delay.js » ('j') | src/date-delay.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
===================================================================
--- src/d8.cc (revision 1587)
+++ src/d8.cc (working copy)
@@ -86,7 +86,7 @@
}
-Shell::CounterMap Shell::counter_map_;
+CounterMap* Shell::counter_map_;
i::OS::MemoryMappedFile* Shell::counters_file_ = NULL;
CounterCollection Shell::local_counters_;
CounterCollection* Shell::counters_ = &local_counters_;
@@ -94,6 +94,13 @@
Persistent<Context> Shell::evaluation_context_;
+bool CounterMap::Match(void* key1, void* key2) {
+ const char* name1 = reinterpret_cast<const char*>(key1);
+ const char* name2 = reinterpret_cast<const char*>(key2);
+ return !strcmp(name1, name2);
Kevin Millikin (Chromium) 2009/03/24 13:29:30 return strcmp(name1, name2) == 0; maybe?
+}
+
+
// Converts a V8 value to a C string.
const char* ToCString(const v8::String::Utf8Value& value) {
return *value ? *value : "<string conversion failed>";
@@ -298,20 +305,31 @@
}
+int CounterMap::Hash(const char* name) {
+ int h = 0;
+ int c;
+ while ((c = *name++) != 0) {
+ h += h << 5;
+ h += c;
+ }
+ return h;
+}
+
+
int* Shell::LookupCounter(const char* name) {
- CounterMap::iterator item = counter_map_.find(name);
- if (item != counter_map_.end()) {
- Counter* result = (*item).second;
- return result->ptr();
+ Counter* counter = counter_map_->Lookup(name);
+ if (counter != NULL) {
+ return counter->ptr();
}
Counter* result = counters_->GetNextCounter();
if (result == NULL) return NULL;
- counter_map_[name] = result;
+ counter_map_->Set(name, result);
return result->Bind(name);
}
void Shell::Initialize() {
+ Shell::counter_map_ = new CounterMap();
// Set up counters
if (i::FLAG_map_counters != NULL)
MapCounters(i::FLAG_map_counters);
@@ -382,11 +400,9 @@
::printf("+----------------------------------------+-------------+\n");
::printf("| Name | Value |\n");
::printf("+----------------------------------------+-------------+\n");
- for (CounterMap::iterator i = counter_map_.begin();
- i != counter_map_.end();
- i++) {
- Counter* counter = (*i).second;
- ::printf("| %-38s | %11i |\n", (*i).first, counter->value());
+ for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) {
+ Counter* counter = i.CurrentValue();
+ ::printf("| %-38s | %11i |\n", i.CurrentKey(), counter->value());
}
::printf("+----------------------------------------+-------------+\n");
}
« no previous file with comments | « src/d8.h ('k') | src/date-delay.js » ('j') | src/date-delay.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698