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

Side by Side Diff: src/profiler/strings-storage.cc

Issue 2173403002: Replace SmartArrayPointer<T> with unique_ptr<T[]> (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « src/perf-jit.cc ('k') | src/regexp/jsregexp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/profiler/strings-storage.h" 5 #include "src/profiler/strings-storage.h"
6 6
7 #include <memory>
8
7 #include "src/base/smart-pointers.h" 9 #include "src/base/smart-pointers.h"
8 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
9 11
10 namespace v8 { 12 namespace v8 {
11 namespace internal { 13 namespace internal {
12 14
13 15
14 bool StringsStorage::StringsMatch(void* key1, void* key2) { 16 bool StringsStorage::StringsMatch(void* key1, void* key2) {
15 return strcmp(reinterpret_cast<char*>(key1), reinterpret_cast<char*>(key2)) == 17 return strcmp(reinterpret_cast<char*>(key1), reinterpret_cast<char*>(key2)) ==
16 0; 18 0;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 76 }
75 return AddOrDisposeString(str.start(), len); 77 return AddOrDisposeString(str.start(), len);
76 } 78 }
77 79
78 80
79 const char* StringsStorage::GetName(Name* name) { 81 const char* StringsStorage::GetName(Name* name) {
80 if (name->IsString()) { 82 if (name->IsString()) {
81 String* str = String::cast(name); 83 String* str = String::cast(name);
82 int length = Min(kMaxNameSize, str->length()); 84 int length = Min(kMaxNameSize, str->length());
83 int actual_length = 0; 85 int actual_length = 0;
84 base::SmartArrayPointer<char> data = str->ToCString( 86 std::unique_ptr<char[]> data = str->ToCString(
85 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL, 0, length, &actual_length); 87 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL, 0, length, &actual_length);
86 return AddOrDisposeString(data.Detach(), actual_length); 88 return AddOrDisposeString(data.release(), actual_length);
87 } else if (name->IsSymbol()) { 89 } else if (name->IsSymbol()) {
88 return "<symbol>"; 90 return "<symbol>";
89 } 91 }
90 return ""; 92 return "";
91 } 93 }
92 94
93 95
94 const char* StringsStorage::GetName(int index) { 96 const char* StringsStorage::GetName(int index) {
95 return GetFormatted("%d", index); 97 return GetFormatted("%d", index);
96 } 98 }
(...skipping 18 matching lines...) Expand all
115 } 117 }
116 return size; 118 return size;
117 } 119 }
118 120
119 base::HashMap::Entry* StringsStorage::GetEntry(const char* str, int len) { 121 base::HashMap::Entry* StringsStorage::GetEntry(const char* str, int len) {
120 uint32_t hash = StringHasher::HashSequentialString(str, len, hash_seed_); 122 uint32_t hash = StringHasher::HashSequentialString(str, len, hash_seed_);
121 return names_.LookupOrInsert(const_cast<char*>(str), hash); 123 return names_.LookupOrInsert(const_cast<char*>(str), hash);
122 } 124 }
123 } // namespace internal 125 } // namespace internal
124 } // namespace v8 126 } // namespace v8
OLDNEW
« no previous file with comments | « src/perf-jit.cc ('k') | src/regexp/jsregexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698