Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 int len = OS::VSNPrintF(str, format, args); | 141 int len = OS::VSNPrintF(str, format, args); |
| 142 if (len == -1) { | 142 if (len == -1) { |
| 143 DeleteArray(str.start()); | 143 DeleteArray(str.start()); |
| 144 return format; | 144 return format; |
| 145 } | 145 } |
| 146 uint32_t hash = HashSequentialString(str.start(), len); | 146 uint32_t hash = HashSequentialString(str.start(), len); |
| 147 return AddOrDisposeString(str.start(), hash); | 147 return AddOrDisposeString(str.start(), hash); |
| 148 } | 148 } |
| 149 | 149 |
| 150 | 150 |
| 151 const uint32_t StringsStorage::kMaxNameSize = 1024; | |
| 152 | |
| 151 const char* StringsStorage::GetName(String* name) { | 153 const char* StringsStorage::GetName(String* name) { |
| 152 if (name->IsString()) { | 154 if (name->IsString()) { |
| 153 return AddOrDisposeString( | 155 uint32_t length = name->length(); |
| 154 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL).Detach(), | 156 length = kMaxNameSize > length ? length : kMaxNameSize; |
|
mnaganov (inactive)
2011/11/09 11:45:23
length = Min(length, kMaxNameSize)
| |
| 155 name->Hash()); | 157 SmartArrayPointer<char> data = |
| 158 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL, 0, length); | |
| 159 uint32_t hash = HashSequentialString(*data, length); | |
| 160 return AddOrDisposeString(data.Detach(), hash); | |
| 156 } | 161 } |
| 157 return ""; | 162 return ""; |
| 158 } | 163 } |
| 159 | 164 |
| 160 | 165 |
| 161 const char* StringsStorage::GetName(int index) { | 166 const char* StringsStorage::GetName(int index) { |
| 162 return GetFormatted("%d", index); | 167 return GetFormatted("%d", index); |
| 163 } | 168 } |
| 164 | 169 |
| 165 | 170 |
| (...skipping 3241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3407 | 3412 |
| 3408 | 3413 |
| 3409 void HeapSnapshotJSONSerializer::SortHashMap( | 3414 void HeapSnapshotJSONSerializer::SortHashMap( |
| 3410 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3415 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
| 3411 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3416 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
| 3412 sorted_entries->Add(p); | 3417 sorted_entries->Add(p); |
| 3413 sorted_entries->Sort(SortUsingEntryValue); | 3418 sorted_entries->Sort(SortUsingEntryValue); |
| 3414 } | 3419 } |
| 3415 | 3420 |
| 3416 } } // namespace v8::internal | 3421 } } // namespace v8::internal |
| OLD | NEW |