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

MDEV-19586: Avoid std::map::emplace()

GCC 4.7 only knows about std::map::insert(), not emplace().

Also, reformat the function in the common style.
parent b7fc2c89
...@@ -1734,9 +1734,9 @@ inline void recv_sys_t::add(mlog_id_t type, const page_id_t page_id, ...@@ -1734,9 +1734,9 @@ inline void recv_sys_t::add(mlog_id_t type, const page_id_t page_id,
ut_ad(type != MLOG_INDEX_LOAD); ut_ad(type != MLOG_INDEX_LOAD);
ut_ad(type != MLOG_TRUNCATE); ut_ad(type != MLOG_TRUNCATE);
std::pair<map::iterator, bool> p = pages.emplace( std::pair<map::iterator, bool> p = pages.insert(map::value_type
map::value_type(page_id, page_recv_t())); (page_id, page_recv_t()));
page_recv_t& recs = p.first->second; page_recv_t& recs= p.first->second;
ut_ad(p.second == recs.log.empty()); ut_ad(p.second == recs.log.empty());
switch (type) { switch (type) {
...@@ -1749,25 +1749,21 @@ inline void recv_sys_t::add(mlog_id_t type, const page_id_t page_id, ...@@ -1749,25 +1749,21 @@ inline void recv_sys_t::add(mlog_id_t type, const page_id_t page_id,
break; break;
} }
/* Store the log record body in chunks of less than srv_page_size: /* Store the log record body in limited-size chunks, because the
heap grows into the buffer pool, and bigger chunks could not heap grows into the buffer pool. */
be allocated */ uint32_t len= uint32_t(rec_end - body);
uint32_t len = uint32_t(rec_end - body); const uint32_t chunk_limit= static_cast<uint32_t>(RECV_DATA_BLOCK_SIZE);
const uint32_t chunk_limit = static_cast<uint32_t>( uint32_t chunk_len= std::min(len, chunk_limit);
RECV_DATA_BLOCK_SIZE);
uint32_t chunk_len = std::min(len, chunk_limit);
recv_t* recv = new recv_t* recv= new (mem_heap_alloc(heap, sizeof(recv_t) + chunk_len))
(mem_heap_alloc(heap, sizeof(recv_t) + chunk_len))
recv_t(len, type, lsn, end_lsn); recv_t(len, type, lsn, end_lsn);
memcpy(recv + 1, body, chunk_len); memcpy(recv + 1, body, chunk_len);
recs.log.append(recv); recs.log.append(recv);
if (UNIV_LIKELY(len == chunk_len)) { if (UNIV_LIKELY(len == chunk_len))
return; return;
}
recv_t::data_t** prev_field = &recv->data.next; recv_t::data_t** prev_field= &recv->data.next;
do { do {
body += chunk_len; body += chunk_len;
...@@ -1775,16 +1771,14 @@ inline void recv_sys_t::add(mlog_id_t type, const page_id_t page_id, ...@@ -1775,16 +1771,14 @@ inline void recv_sys_t::add(mlog_id_t type, const page_id_t page_id,
chunk_len = std::min(len, chunk_limit); chunk_len = std::min(len, chunk_limit);
recv_t::data_t* recv_data = static_cast<recv_t::data_t*> recv_t::data_t* recv_data = static_cast<recv_t::data_t*>
(mem_heap_alloc(heap, sizeof(recv_t::data_t) (mem_heap_alloc(heap, sizeof(recv_t::data_t) + chunk_len));
+ chunk_len));
*prev_field = recv_data; *prev_field = recv_data;
memcpy(recv_data + 1, body, chunk_len); memcpy(recv_data + 1, body, chunk_len);
prev_field= &recv_data->next;
prev_field = &recv_data->next;
} while (len != chunk_len); } while (len != chunk_len);
*prev_field = NULL; *prev_field= NULL;
} }
/** Trim old log records for a page /** Trim old log records for a page
......
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