Chromium Code Reviews| Index: runtime/vm/intrinsifier.cc |
| diff --git a/runtime/vm/intrinsifier.cc b/runtime/vm/intrinsifier.cc |
| index 9e4188b4af83cd58d4da508bfa5010a2a4fbb3c6..fcb937885255c2c5641ed881dabb711ff52bbdc9 100644 |
| --- a/runtime/vm/intrinsifier.cc |
| +++ b/runtime/vm/intrinsifier.cc |
| @@ -13,28 +13,44 @@ DEFINE_FLAG(bool, intrinsify, true, "Instrinsify when possible"); |
| static bool CompareNames(const char* test_name, const char* name) { |
| - if (strcmp(test_name, name) == 0) { |
| - return true; |
| - } |
| - if ((name[0] == '_') && (test_name[0] == '_')) { |
| - // Check if the private class is member of core or scalarlist and matches |
| - // the test_class_name. |
| - const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| - const Library& scalarlist_lib = |
| - Library::Handle(Library::ScalarlistLibrary()); |
| - String& test_str = String::Handle(String::New(test_name)); |
| - String& test_str_with_key = String::Handle(); |
| - test_str_with_key = |
| - String::Concat(test_str, String::Handle(core_lib.private_key())); |
| - if (strcmp(test_str_with_key.ToCString(), name) == 0) { |
| - return true; |
| + static const intptr_t kPrefixLength = 5; |
| + static const char* kGetterPrefix = "get:_"; |
| + static const char* kSetterPrefix = "set:_"; |
|
Florian Schneider
2013/01/07 13:15:48
I'd define those in one place and remove kPrefixLe
Vyacheslav Egorov (Google)
2013/01/07 15:02:47
I renamed & started to use strlen.
I am however
|
| + |
| + if (test_name[0] == '_') { |
| + if (name[0] != '_') { |
| + return false; |
| } |
| - test_str_with_key = |
| - String::Concat(test_str, String::Handle(scalarlist_lib.private_key())); |
| - if (strcmp(test_str_with_key.ToCString(), name) == 0) { |
| - return true; |
| + } else if (strncmp(test_name, kGetterPrefix, kPrefixLength) == 0) { |
| + if (strncmp(name, kGetterPrefix, kPrefixLength) != 0) { |
| + return false; |
| + } |
| + } else if (strncmp(test_name, kSetterPrefix, kPrefixLength) == 0) { |
| + if (strncmp(name, kSetterPrefix, kPrefixLength) != 0) { |
| + return false; |
| } |
| + } else { |
| + return (strcmp(test_name, name) == 0); |
| } |
| + |
| + // Check if the private class is member of core or scalarlist and matches |
| + // the test_class_name. |
| + const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| + const Library& scalarlist_lib = |
| + Library::Handle(Library::ScalarlistLibrary()); |
| + String& test_str = String::Handle(String::New(test_name)); |
| + String& test_str_with_key = String::Handle(); |
| + test_str_with_key = |
| + String::Concat(test_str, String::Handle(core_lib.private_key())); |
| + if (strcmp(test_str_with_key.ToCString(), name) == 0) { |
| + return true; |
| + } |
| + test_str_with_key = |
| + String::Concat(test_str, String::Handle(scalarlist_lib.private_key())); |
| + if (strcmp(test_str_with_key.ToCString(), name) == 0) { |
| + return true; |
| + } |
| + |
| return false; |
| } |