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

Unified Diff: runtime/vm/object.h

Issue 400493002: Hide dangerous interface String::Equals/Hash(uint8_t*,... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/object_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
===================================================================
--- runtime/vm/object.h (revision 38266)
+++ runtime/vm/object.h (working copy)
@@ -5357,7 +5357,7 @@
static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); }
static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len);
- static intptr_t Hash(const uint8_t* characters, intptr_t len);
+ static intptr_t HashLatin1(const uint8_t* characters, intptr_t len);
static intptr_t Hash(const uint16_t* characters, intptr_t len);
static intptr_t Hash(const int32_t* characters, intptr_t len);
@@ -5377,8 +5377,10 @@
// Compares to a '\0' terminated array of UTF-8 encoded characters.
bool Equals(const char* cstr) const;
- // Compares to an array of UTF-8 encoded characters.
- bool Equals(const uint8_t* characters, intptr_t len) const;
+ // Compares to an array of Latin-1 encoded characters.
+ bool EqualsLatin1(const uint8_t* characters, intptr_t len) const {
+ return Equals(characters, len);
+ }
// Compares to an array of UTF-16 encoded characters.
bool Equals(const uint16_t* characters, intptr_t len) const;
@@ -5544,6 +5546,12 @@
double* result);
protected:
+ // These two operate on an array of Latin-1 encoded characters.
+ // They are protected to avoid mistaking Latin-1 for UTF-8, but used
+ // by friendly templated code (e.g., Symbols).
+ bool Equals(const uint8_t* characters, intptr_t len) const;
+ static intptr_t Hash(const uint8_t* characters, intptr_t len);
+
bool HasHash() const {
ASSERT(Smi::New(0) == NULL);
return (raw_ptr()->hash_ != NULL);
« 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