Apply some IIFE to reduce copies

This commit is contained in:
Jason Turner
2015-03-29 21:58:14 -06:00
parent d514fa3346
commit 59103b5a22
2 changed files with 43 additions and 38 deletions

View File

@@ -617,14 +617,16 @@ namespace chaiscript
}
size_t size = sizeof(int) * 8;
if (longlong_)
{
size = sizeof(int64_t) * 8;
} else if (long_) {
size = sizeof(long) * 8;
}
const size_t size = [&](){
if (longlong_)
{
return sizeof(int64_t) * 8;
} else if (long_) {
return sizeof(long) * 8;
} else {
return sizeof(int) * 8;
}
}();
if ( (u >> (size - 1)) > 0)
{
@@ -794,17 +796,19 @@ namespace chaiscript
return Id_();
} else {
const auto start = m_input_pos;
const int prev_col = m_col;
const int prev_line = m_line;
const auto prev_col = m_col;
const auto prev_line = m_line;
if (Id_()) {
std::string match;
if (*start == '`') {
//Id Literal
match = std::string(start+1, m_input_pos-1);
} else {
match = std::string(start, m_input_pos);
}
m_match_stack.push_back(std::make_shared<eval::Id_AST_Node>(std::move(match), m_filename, prev_line, prev_col, m_line, m_col));
m_match_stack.push_back(std::make_shared<eval::Id_AST_Node>(
[&](){
if (*start == '`') {
//Id Literal
return std::string(start+1, m_input_pos-1);
} else {
return std::string(start, m_input_pos);
}
}(),
m_filename, prev_line, prev_col, m_line, m_col));
return true;
} else {
return false;