Commit dc8380b6 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-14602: Cleanup recv_dblwr_t::find_page()

Avoid creating std::vector, and use single instead of double traversal.
parent 2350066e
...@@ -27,7 +27,6 @@ Created 9/20/1997 Heikki Tuuri ...@@ -27,7 +27,6 @@ Created 9/20/1997 Heikki Tuuri
#include "univ.i" #include "univ.i"
#include <vector>
#include <map> #include <map>
#include <string> #include <string>
#include <my_service_manager.h> #include <my_service_manager.h>
...@@ -4044,44 +4043,26 @@ recv_recovery_rollback_active(void) ...@@ -4044,44 +4043,26 @@ recv_recovery_rollback_active(void)
@param[in] page_no page number @param[in] page_no page number
@return page frame @return page frame
@retval NULL if no page was found */ @retval NULL if no page was found */
const byte* const byte*
recv_dblwr_t::find_page(ulint space_id, ulint page_no) recv_dblwr_t::find_page(ulint space_id, ulint page_no)
{ {
typedef std::vector<const byte*, ut_allocator<const byte*> > const byte *result= NULL;
matches_t; lsn_t max_lsn= 0;
matches_t matches; for (list::const_iterator i = pages.begin(); i != pages.end(); ++i)
const byte* result = 0; {
const byte *page= *i;
for (list::iterator i = pages.begin(); i != pages.end(); ++i) { if (page_get_page_no(page) != page_no ||
if (page_get_space_id(*i) == space_id page_get_space_id(page) != space_id)
&& page_get_page_no(*i) == page_no) { continue;
matches.push_back(*i); const lsn_t lsn= mach_read_from_8(page + FIL_PAGE_LSN);
} if (lsn <= max_lsn)
} continue;
max_lsn= lsn;
if (matches.size() == 1) { result= page;
result = matches[0]; }
} else if (matches.size() > 1) {
return result;
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);
} }
#ifndef DBUG_OFF #ifndef DBUG_OFF
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment