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

Side by Side Diff: src/objects-inl.h

Issue 1444001: Some string optimizations: (Closed)
Patch Set: Review fix. Created 10 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 unified diff | Download patch
« no previous file with comments | « src/objects.cc ('k') | src/v8-counters.h » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 bool String::IsTwoByteRepresentation() { 248 bool String::IsTwoByteRepresentation() {
249 uint32_t type = map()->instance_type(); 249 uint32_t type = map()->instance_type();
250 if ((type & kStringRepresentationMask) == kConsStringTag && 250 if ((type & kStringRepresentationMask) == kConsStringTag &&
251 ConsString::cast(this)->second()->length() == 0) { 251 ConsString::cast(this)->second()->length() == 0) {
252 return ConsString::cast(this)->first()->IsTwoByteRepresentation(); 252 return ConsString::cast(this)->first()->IsTwoByteRepresentation();
253 } 253 }
254 return (type & kStringEncodingMask) == kTwoByteStringTag; 254 return (type & kStringEncodingMask) == kTwoByteStringTag;
255 } 255 }
256 256
257 257
258 bool String::IsExternalTwoByteStringWithAsciiChars() {
259 if (!IsExternalTwoByteString()) return false;
260 const uc16* data = ExternalTwoByteString::cast(this)->resource()->data();
261 for (int i = 0, len = length(); i < len; i++) {
262 if (data[i] > kMaxAsciiCharCode) return false;
263 }
264 return true;
265 }
266
267
258 bool StringShape::IsCons() { 268 bool StringShape::IsCons() {
259 return (type_ & kStringRepresentationMask) == kConsStringTag; 269 return (type_ & kStringRepresentationMask) == kConsStringTag;
260 } 270 }
261 271
262 272
263 bool StringShape::IsExternal() { 273 bool StringShape::IsExternal() {
264 return (type_ & kStringRepresentationMask) == kExternalStringTag; 274 return (type_ & kStringRepresentationMask) == kExternalStringTag;
265 } 275 }
266 276
267 277
(...skipping 2817 matching lines...) Expand 10 before | Expand all | Expand 10 after
3085 #undef WRITE_INT_FIELD 3095 #undef WRITE_INT_FIELD
3086 #undef READ_SHORT_FIELD 3096 #undef READ_SHORT_FIELD
3087 #undef WRITE_SHORT_FIELD 3097 #undef WRITE_SHORT_FIELD
3088 #undef READ_BYTE_FIELD 3098 #undef READ_BYTE_FIELD
3089 #undef WRITE_BYTE_FIELD 3099 #undef WRITE_BYTE_FIELD
3090 3100
3091 3101
3092 } } // namespace v8::internal 3102 } } // namespace v8::internal
3093 3103
3094 #endif // V8_OBJECTS_INL_H_ 3104 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/v8-counters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698