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