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

Unified Diff: test/cctest/test-serialize.cc

Issue 99051: Remove dependency on libstdc++ from test framework. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 8 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 | « test/cctest/test-regexp.cc ('k') | tools/test.py » ('j') | tools/test.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-serialize.cc
===================================================================
--- test/cctest/test-serialize.cc (revision 1793)
+++ test/cctest/test-serialize.cc (working copy)
@@ -26,8 +26,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <signal.h>
-#include <map>
-#include <string>
#include "sys/stat.h"
#include "v8.h"
@@ -42,20 +40,40 @@
using namespace v8::internal;
-static int local_counters[256];
-static int counter_count = 0;
-static std::map<std::string, int> counter_table;
+static const unsigned kCounters = 256;
+static int local_counters[kCounters];
+static const char* local_counter_names[kCounters];
+static unsigned CounterHash(const char* s) {
+ unsigned hash = 0;
+ while(*++s) {
+ hash |= hash << 5;
+ hash += *s;
+ }
+ return hash;
+}
+
+
// Callback receiver to track counters in test.
static int* counter_function(const char* name) {
- std::string counter(name);
- if (counter_table.find(counter) == counter_table.end()) {
- local_counters[counter_count] = 0;
- counter_table[counter] = counter_count++;
+ unsigned hash = CounterHash(name) % kCounters;
+ unsigned original_hash = hash;
+ USE(original_hash);
+ while(true) {
+ if (local_counter_names[hash] == name) {
+ return &local_counters[hash];
+ }
+ if (local_counter_names[hash] == 0) {
+ local_counter_names[hash] = name;
+ return &local_counters[hash];
+ }
+ if (strcmp(local_counter_names[hash], name) == 0) {
+ return &local_counters[hash];
+ }
+ hash = (hash + 1) % kCounters;
+ ASSERT(hash != original_hash); // Hash table has been filled up.
}
-
- return &local_counters[counter_table[counter]];
}
« no previous file with comments | « test/cctest/test-regexp.cc ('k') | tools/test.py » ('j') | tools/test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698