diff options
author | Vic Yang <victoryang@google.com> | 2019-06-02 21:10:53 -0700 |
---|---|---|
committer | Vic Yang <victoryang@google.com> | 2019-06-04 21:01:04 -0700 |
commit | 3ec16be2bc371b2ff689ec70cd801f35e21db052 (patch) | |
tree | 17b990a5b5946b167a09ff7f27eedb1e8676f9fd /linker/linker.cpp | |
parent | 44c29535cc472108f98e03575aa902bbe4ccee05 (diff) |
linker: Speed up find_loaded_library_by_inode()
Rearrange the st_dev and st_ino checks to reduce the number of
comparison needed.
Test: Ran cameraserver on a Go device. Measured time spent in the linker
and saw ~1% speed-up.
Change-Id: I8e977ff37925eae3ba8348e7c4a01ce8af3b9b6d
Diffstat (limited to 'linker/linker.cpp')
-rw-r--r-- | linker/linker.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/linker/linker.cpp b/linker/linker.cpp index 7bc3529a0..9bb655792 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -1222,12 +1222,14 @@ static bool find_loaded_library_by_inode(android_namespace_t* ns, off64_t file_offset, bool search_linked_namespaces, soinfo** candidate) { + if (file_stat.st_dev == 0 || file_stat.st_ino == 0) { + *candidate = nullptr; + return false; + } auto predicate = [&](soinfo* si) { - return si->get_st_dev() != 0 && - si->get_st_ino() != 0 && + return si->get_st_ino() == file_stat.st_ino && si->get_st_dev() == file_stat.st_dev && - si->get_st_ino() == file_stat.st_ino && si->get_file_offset() == file_offset; }; |