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

Side by Side Diff: src/vector.h

Issue 501323002: Replace our homegrown ARRAY_SIZE() with Chrome's arraysize(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #ifndef V8_VECTOR_H_ 5 #ifndef V8_VECTOR_H_
6 #define V8_VECTOR_H_ 6 #define V8_VECTOR_H_
7 7
8 #include <string.h> 8 #include <string.h>
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 inline int StrLength(const char* string) { 147 inline int StrLength(const char* string) {
148 size_t length = strlen(string); 148 size_t length = strlen(string);
149 DCHECK(length == static_cast<size_t>(static_cast<int>(length))); 149 DCHECK(length == static_cast<size_t>(static_cast<int>(length)));
150 return static_cast<int>(length); 150 return static_cast<int>(length);
151 } 151 }
152 152
153 153
154 #define STATIC_ASCII_VECTOR(x) \ 154 #define STATIC_ASCII_VECTOR(x) \
155 v8::internal::Vector<const uint8_t>(reinterpret_cast<const uint8_t*>(x), \ 155 v8::internal::Vector<const uint8_t>(reinterpret_cast<const uint8_t*>(x), \
156 ARRAY_SIZE(x)-1) 156 arraysize(x)-1)
157 157
158 inline Vector<const char> CStrVector(const char* data) { 158 inline Vector<const char> CStrVector(const char* data) {
159 return Vector<const char>(data, StrLength(data)); 159 return Vector<const char>(data, StrLength(data));
160 } 160 }
161 161
162 inline Vector<const uint8_t> OneByteVector(const char* data, int length) { 162 inline Vector<const uint8_t> OneByteVector(const char* data, int length) {
163 return Vector<const uint8_t>(reinterpret_cast<const uint8_t*>(data), length); 163 return Vector<const uint8_t>(reinterpret_cast<const uint8_t*>(data), length);
164 } 164 }
165 165
166 inline Vector<const uint8_t> OneByteVector(const char* data) { 166 inline Vector<const uint8_t> OneByteVector(const char* data) {
167 return OneByteVector(data, StrLength(data)); 167 return OneByteVector(data, StrLength(data));
168 } 168 }
169 169
170 inline Vector<char> MutableCStrVector(char* data) { 170 inline Vector<char> MutableCStrVector(char* data) {
171 return Vector<char>(data, StrLength(data)); 171 return Vector<char>(data, StrLength(data));
172 } 172 }
173 173
174 inline Vector<char> MutableCStrVector(char* data, int max) { 174 inline Vector<char> MutableCStrVector(char* data, int max) {
175 int length = StrLength(data); 175 int length = StrLength(data);
176 return Vector<char>(data, (length < max) ? length : max); 176 return Vector<char>(data, (length < max) ? length : max);
177 } 177 }
178 178
179 179
180 } } // namespace v8::internal 180 } } // namespace v8::internal
181 181
182 #endif // V8_VECTOR_H_ 182 #endif // V8_VECTOR_H_
OLDNEW
« src/base/macros.h ('K') | « src/types.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698