Commit 72136ae7 authored by Eugene Kosov's avatar Eugene Kosov Committed by Sergey Vojtovich

Compilation speed (#546)

Speed up compilation

Standard C++ headers contribute a lot to compilation time. Avoid algorithm
and sstream in frequently used headers.
parent fc655778
......@@ -195,10 +195,14 @@ void debug_sync_point(const char* lock_name, uint lock_timeout);
#ifdef __cplusplus
}
/*
DBUG_LOG() was initially intended for InnoDB. To be able to use it elsewhere
one should #include <sstream>. We intentially avoid including it here to save
compilation time.
*/
# ifdef DBUG_OFF
# define DBUG_LOG(keyword, v) do {} while (0)
# else
# include <sstream>
# define DBUG_LOG(keyword, v) do { \
if (_db_pargs_(__LINE__, keyword)) { \
std::ostringstream _db_s; _db_s << v; \
......
......@@ -2889,7 +2889,7 @@ bool Item_func_min_max::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
ltime->hour+= (ltime->month * 32 + ltime->day) * 24;
ltime->year= ltime->month= ltime->day= 0;
if (adjust_time_range_with_warn(ltime,
std::min<uint>(decimals, TIME_SECOND_PART_DIGITS)))
MY_MIN(decimals, TIME_SECOND_PART_DIGITS)))
return (null_value= true);
}
......
......@@ -2257,7 +2257,7 @@ bool Item_sum_bit::remove_as_window(ulonglong value)
}
// Prevent overflow;
num_values_added = std::min(num_values_added, num_values_added - 1);
num_values_added = MY_MIN(num_values_added, num_values_added - 1);
set_bits_from_counters();
return 0;
}
......@@ -2270,7 +2270,7 @@ bool Item_sum_bit::add_as_window(ulonglong value)
bit_counters[i]+= (value & (1ULL << i)) ? 1 : 0;
}
// Prevent overflow;
num_values_added = std::max(num_values_added, num_values_added + 1);
num_values_added = MY_MAX(num_values_added, num_values_added + 1);
set_bits_from_counters();
return 0;
}
......
......@@ -21,9 +21,6 @@
#include "key.h" // key_rec_cmp
#include "field.h" // Field
using std::min;
using std::max;
/*
Search after a key that starts with 'field'
......@@ -135,7 +132,7 @@ void key_copy(uchar *to_key, uchar *from_record, KEY *key_info,
Don't copy data for null values
The -1 below is to subtract the null byte which is already handled
*/
length= min<uint>(key_length, key_part->store_length-1);
length= MY_MIN(key_length, key_part->store_length-1);
if (with_zerofill)
bzero((char*) to_key, length);
continue;
......@@ -145,7 +142,7 @@ void key_copy(uchar *to_key, uchar *from_record, KEY *key_info,
key_part->key_part_flag & HA_VAR_LENGTH_PART)
{
key_length-= HA_KEY_BLOB_LENGTH;
length= min<uint>(key_length, key_part->length);
length= MY_MIN(key_length, key_part->length);
uint bytes= key_part->field->get_key_image(to_key, length, Field::itRAW);
if (with_zerofill && bytes < length)
bzero((char*) to_key + bytes, length - bytes);
......@@ -153,7 +150,7 @@ void key_copy(uchar *to_key, uchar *from_record, KEY *key_info,
}
else
{
length= min<uint>(key_length, key_part->length);
length= MY_MIN(key_length, key_part->length);
Field *field= key_part->field;
CHARSET_INFO *cs= field->charset();
uint bytes= field->get_key_image(to_key, length, Field::itRAW);
......@@ -205,7 +202,7 @@ void key_restore(uchar *to_record, const uchar *from_key, KEY *key_info,
Don't copy data for null bytes
The -1 below is to subtract the null byte which is already handled
*/
length= min<uint>(key_length, key_part->store_length-1);
length= MY_MIN(key_length, key_part->store_length-1);
continue;
}
}
......@@ -247,7 +244,7 @@ void key_restore(uchar *to_record, const uchar *from_key, KEY *key_info,
my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
field->move_field_offset(ptrdiff);
key_length-= HA_KEY_BLOB_LENGTH;
length= min<uint>(key_length, key_part->length);
length= MY_MIN(key_length, key_part->length);
old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
field->set_key_image(from_key, length);
dbug_tmp_restore_column_map(field->table->write_set, old_map);
......@@ -256,7 +253,7 @@ void key_restore(uchar *to_record, const uchar *from_key, KEY *key_info,
}
else
{
length= min<uint>(key_length, key_part->length);
length= MY_MIN(key_length, key_part->length);
/* skip the byte with 'uneven' bits, if used */
memcpy(to_record + key_part->offset, from_key + used_uneven_bits
, (size_t) length - used_uneven_bits);
......@@ -314,7 +311,7 @@ bool key_cmp_if_same(TABLE *table,const uchar *key,uint idx,uint key_length)
return 1;
continue;
}
length= min((uint) (key_end-key), store_length);
length= MY_MIN((uint) (key_end-key), store_length);
if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
FIELDFLAG_PACK)))
{
......@@ -392,7 +389,7 @@ void field_unpack(String *to, Field *field, const uchar *rec, uint max_length,
tmp.length(charpos);
}
if (max_length < field->pack_length())
tmp.length(min(tmp.length(),max_length));
tmp.length(MY_MIN(tmp.length(),max_length));
ErrConvString err(&tmp);
to->append(err.ptr());
}
......
......@@ -7044,7 +7044,7 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
int4store(ev + EVENT_LEN_OFFSET, ev_len + writer.checksum_len);
writer.remains= ev_len;
if (writer.write(ev, std::min<uint>(ev_len, length - hdr_offs)))
if (writer.write(ev, MY_MIN(ev_len, length - hdr_offs)))
DBUG_RETURN(ER_ERROR_ON_WRITE);
/* next event header at ... */
......
......@@ -55,8 +55,6 @@
#define my_b_write_string(A, B) my_b_write((A), (uchar*)(B), (uint) (sizeof(B) - 1))
using std::max;
/**
BINLOG_CHECKSUM variable.
*/
......@@ -1777,8 +1775,8 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,
if (data_len < LOG_EVENT_MINIMAL_HEADER_LEN)
DBUG_RETURN(LOG_READ_BOGUS);
if (data_len > max(max_allowed_packet,
opt_binlog_rows_event_max_size + MAX_LOG_EVENT_HEADER))
if (data_len > MY_MAX(max_allowed_packet,
opt_binlog_rows_event_max_size + MAX_LOG_EVENT_HEADER))
DBUG_RETURN(LOG_READ_TOO_LARGE);
if (likely(data_len > LOG_EVENT_MINIMAL_HEADER_LEN))
......
......@@ -21,8 +21,6 @@
#include <mysql_com.h>
#include <lf.h>
#include <algorithm>
class THD;
class MDL_context;
......@@ -373,8 +371,7 @@ class MDL_key
character set is utf-8, we can safely assume that no
character starts with a zero byte.
*/
using std::min;
return memcmp(m_ptr, rhs->m_ptr, min(m_length, rhs->m_length));
return memcmp(m_ptr, rhs->m_ptr, MY_MIN(m_length, rhs->m_length));
}
MDL_key(const MDL_key *rhs)
......
......@@ -41,7 +41,6 @@
#include "sp_head.h"
#include "pfs_digest.h"
using std::min;
/**
@page PAGE_PERFORMANCE_SCHEMA The Performance Schema main page
MySQL PERFORMANCE_SCHEMA implementation.
......@@ -2022,7 +2021,7 @@ static void set_thread_account_v1(const char *user, int user_len,
DBUG_ASSERT((host != NULL) || (host_len == 0));
DBUG_ASSERT(host_len >= 0);
host_len= min<size_t>(host_len, sizeof(pfs->m_hostname));
host_len= MY_MIN(host_len, static_cast<int>(sizeof(pfs->m_hostname)));
if (unlikely(pfs == NULL))
return;
......
......@@ -257,8 +257,8 @@ int table_threads::read_row_values(TABLE *table,
changed to less than or equal to 64 characters.
*/
set_field_varchar_utf8(f, m_row.m_processlist_state_ptr,
std::min<uint>(m_row.m_processlist_state_length,
f->char_length()));
MY_MIN(m_row.m_processlist_state_length,
f->char_length()));
}
else
f->set_null();
......
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