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

Unified Diff: runtime/vm/object.h

Issue 1666113002: Improve performance of Library::LookupLibrary(const String&). (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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.cc » ('j') | runtime/vm/object.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 1715a13a293a8ae1b354697908eb522cd39752a3..308a02c7defd77a114aa2a4a84feafbcf3e16303 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -6288,6 +6288,7 @@ class String : public Instance {
this->SetHash(result);
return result;
}
+
bool HasHash() const {
ASSERT(Smi::New(0) == NULL);
return (raw_ptr()->hash_ != NULL);
@@ -6317,9 +6318,10 @@ class String : public Instance {
intptr_t CharSize() const;
inline bool Equals(const String& str) const;
- inline bool Equals(const String& str,
- intptr_t begin_index, // begin index on 'str'.
- intptr_t len) const; // len on 'str'.
+
+ bool Equals(const String& str,
+ intptr_t begin_index, // begin index on 'str'.
+ intptr_t len) const; // len on 'str'.
// Compares to a '\0' terminated array of UTF-8 encoded characters.
bool Equals(const char* cstr) const;
@@ -8354,26 +8356,13 @@ bool String::Equals(const String& str) const {
if (str.IsNull()) {
kasperl 2016/02/05 05:09:26 This takes care of the null check I removed from S
Ivan Posva 2016/02/05 05:57:42 Acknowledged.
return false;
}
- return Equals(str, 0, str.Length());
-}
-
-
-bool String::Equals(const String& str,
- intptr_t begin_index,
- intptr_t len) const {
- ASSERT(begin_index >= 0);
- ASSERT((begin_index == 0) || (begin_index < str.Length()));
- ASSERT(len >= 0);
- ASSERT(len <= str.Length());
- if (len != this->Length()) {
- return false; // Lengths don't match.
+ if (IsCanonical() && str.IsCanonical()) {
+ return false; // Two symbols that aren't identical aren't equal.
}
- for (intptr_t i = 0; i < len; i++) {
- if (this->CharAt(i) != str.CharAt(begin_index + i)) {
- return false;
- }
+ if (HasHash() && str.HasHash() && (Hash() != str.Hash())) {
+ return false; // Both sides have hash codes and they do not match.
}
- return true;
+ return Equals(str, 0, str.Length());
}
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698