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

Side by Side Diff: src/objects.cc

Issue 7064017: Add fast cases for flat comparison to String::Is{Ascii,TwoByte}EqualTo. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5491 matching lines...) Expand 10 before | Expand all | Expand 10 after
5502 uc32 r = decoder->GetNext(); 5502 uc32 r = decoder->GetNext();
5503 if (Get(i) != r) return false; 5503 if (Get(i) != r) return false;
5504 } 5504 }
5505 return i == slen && !decoder->has_more(); 5505 return i == slen && !decoder->has_more();
5506 } 5506 }
5507 5507
5508 5508
5509 bool String::IsAsciiEqualTo(Vector<const char> str) { 5509 bool String::IsAsciiEqualTo(Vector<const char> str) {
5510 int slen = length(); 5510 int slen = length();
5511 if (str.length() != slen) return false; 5511 if (str.length() != slen) return false;
5512 if (IsFlat() && IsAsciiRepresentation()) {
Erik Corry 2011/05/24 07:14:07 CompareChars doesn't require that the two strings
5513 return CompareChars(ToAsciiVector().start(), str.start(), slen) == 0;
5514 }
5512 for (int i = 0; i < slen; i++) { 5515 for (int i = 0; i < slen; i++) {
5513 if (Get(i) != static_cast<uint16_t>(str[i])) return false; 5516 if (Get(i) != static_cast<uint16_t>(str[i])) return false;
5514 } 5517 }
5515 return true; 5518 return true;
5516 } 5519 }
5517 5520
5518 5521
5519 bool String::IsTwoByteEqualTo(Vector<const uc16> str) { 5522 bool String::IsTwoByteEqualTo(Vector<const uc16> str) {
5520 int slen = length(); 5523 int slen = length();
5521 if (str.length() != slen) return false; 5524 if (str.length() != slen) return false;
5525 if (IsFlat() && IsTwoByteRepresentation()) {
5526 return CompareChars(ToUC16Vector().start(), str.start(), slen) == 0;
5527 }
5522 for (int i = 0; i < slen; i++) { 5528 for (int i = 0; i < slen; i++) {
5523 if (Get(i) != str[i]) return false; 5529 if (Get(i) != str[i]) return false;
5524 } 5530 }
5525 return true; 5531 return true;
5526 } 5532 }
5527 5533
5528 5534
5529 uint32_t String::ComputeAndSetHash() { 5535 uint32_t String::ComputeAndSetHash() {
5530 // Should only be called if hash code has not yet been computed. 5536 // Should only be called if hash code has not yet been computed.
5531 ASSERT(!HasHashCode()); 5537 ASSERT(!HasHashCode());
(...skipping 4962 matching lines...) Expand 10 before | Expand all | Expand 10 after
10494 if (break_point_objects()->IsUndefined()) return 0; 10500 if (break_point_objects()->IsUndefined()) return 0;
10495 // Single beak point. 10501 // Single beak point.
10496 if (!break_point_objects()->IsFixedArray()) return 1; 10502 if (!break_point_objects()->IsFixedArray()) return 1;
10497 // Multiple break points. 10503 // Multiple break points.
10498 return FixedArray::cast(break_point_objects())->length(); 10504 return FixedArray::cast(break_point_objects())->length();
10499 } 10505 }
10500 #endif 10506 #endif
10501 10507
10502 10508
10503 } } // namespace v8::internal 10509 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698