diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-11-12 14:41:24 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-11-12 14:41:24 +0200 |
commit | dc8380b65da2071735129c829a3ea7bca006bf5c (patch) | |
tree | c49dc4c1b7c0f29d8227a6b6e463151a0b506d7a | |
parent | 2350066e639e532af0a2f3ee62442c6757869f2c (diff) | |
download | mariadb-git-dc8380b65da2071735129c829a3ea7bca006bf5c.tar.gz |
MDEV-14602: Cleanup recv_dblwr_t::find_page()
Avoid creating std::vector, and use single instead of double traversal.
-rw-r--r-- | storage/innobase/log/log0recv.cc | 53 |
1 files changed, 17 insertions, 36 deletions
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 3068a510b4e..9a20c7f7d22 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -27,7 +27,6 @@ Created 9/20/1997 Heikki Tuuri #include "univ.i" -#include <vector> #include <map> #include <string> #include <my_service_manager.h> @@ -4044,44 +4043,26 @@ recv_recovery_rollback_active(void) @param[in] page_no page number @return page frame @retval NULL if no page was found */ - const byte* recv_dblwr_t::find_page(ulint space_id, ulint page_no) { - typedef std::vector<const byte*, ut_allocator<const byte*> > - matches_t; - - matches_t matches; - const byte* result = 0; - - for (list::iterator i = pages.begin(); i != pages.end(); ++i) { - if (page_get_space_id(*i) == space_id - && page_get_page_no(*i) == page_no) { - matches.push_back(*i); - } - } - - if (matches.size() == 1) { - result = matches[0]; - } else if (matches.size() > 1) { - - lsn_t max_lsn = 0; - lsn_t page_lsn = 0; - - for (matches_t::iterator i = matches.begin(); - i != matches.end(); - ++i) { - - page_lsn = mach_read_from_8(*i + FIL_PAGE_LSN); - - if (page_lsn > max_lsn) { - max_lsn = page_lsn; - result = *i; - } - } - } - - return(result); + const byte *result= NULL; + lsn_t max_lsn= 0; + + for (list::const_iterator i = pages.begin(); i != pages.end(); ++i) + { + const byte *page= *i; + if (page_get_page_no(page) != page_no || + page_get_space_id(page) != space_id) + continue; + const lsn_t lsn= mach_read_from_8(page + FIL_PAGE_LSN); + if (lsn <= max_lsn) + continue; + max_lsn= lsn; + result= page; + } + + return result; } #ifndef DBUG_OFF |