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

Side by Side Diff: runtime/vm/object.cc

Issue 8360027: Proper string comparison. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressing comments Created 9 years, 1 month 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 | runtime/vm/object_test.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 (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/assert.h" 8 #include "vm/assert.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 5342 matching lines...) Expand 10 before | Expand all | Expand 10 after
5353 // Lengths don't match. 5353 // Lengths don't match.
5354 return false; 5354 return false;
5355 } 5355 }
5356 int32_t ch; 5356 int32_t ch;
5357 intptr_t consumed = Utf8::Decode(str, &ch); 5357 intptr_t consumed = Utf8::Decode(str, &ch);
5358 if (consumed == 0 || this->CharAt(i) != ch) { 5358 if (consumed == 0 || this->CharAt(i) != ch) {
5359 return false; 5359 return false;
5360 } 5360 }
5361 str += consumed; 5361 str += consumed;
5362 } 5362 }
5363 return true; 5363 return *str == '\0';
5364 } 5364 }
5365 5365
5366 5366
5367 bool String::Equals(const uint8_t* characters, intptr_t len) const { 5367 bool String::Equals(const uint8_t* characters, intptr_t len) const {
5368 if (len != this->Length()) { 5368 if (len != this->Length()) {
5369 // Lengths don't match. 5369 // Lengths don't match.
5370 return false; 5370 return false;
5371 } 5371 }
5372 5372
5373 for (intptr_t i = 0; i < len; i++) { 5373 for (intptr_t i = 0; i < len; i++) {
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after
6793 const String& str = String::Handle(pattern()); 6793 const String& str = String::Handle(pattern());
6794 const char* format = "JSRegExp: pattern=%s flags=%s"; 6794 const char* format = "JSRegExp: pattern=%s flags=%s";
6795 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 6795 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
6796 char* chars = reinterpret_cast<char*>( 6796 char* chars = reinterpret_cast<char*>(
6797 Isolate::Current()->current_zone()->Allocate(len + 1)); 6797 Isolate::Current()->current_zone()->Allocate(len + 1));
6798 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 6798 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
6799 return chars; 6799 return chars;
6800 } 6800 }
6801 6801
6802 } // namespace dart 6802 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698