| 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]];
|
| }
|
|
|
|
|
|
|