Skip to content

Commit

Permalink
S3select: replacing a "naked loop" with std::copy_n
Browse files Browse the repository at this point in the history
... and fixing some extra copying

Signed-off-by: Ronen Friedman <[email protected]>
  • Loading branch information
ronen-fr committed Dec 14, 2020
1 parent 81f5e17 commit 0f15a1b
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions include/s3select_oper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <list>
#include <map>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>

Expand Down Expand Up @@ -227,27 +228,17 @@ class scratch_area
m_column_name_pos.push_back( std::pair<const char*, int>(n, pos));
}

void update(std::vector<char*>& tokens, size_t num_of_tokens)
void update(const std::vector<char*>& tokens, size_t num_of_tokens)
{
size_t i=0;
for(auto s : tokens)
{
if (i>=num_of_tokens)
{
break;
}

m_columns[i++] = s;
}
m_upper_bound = i;

std::copy_n(tokens.begin(), num_of_tokens, m_columns.begin());
m_upper_bound = num_of_tokens;
}

int get_column_pos(const char* n)
{
//done only upon building the AST, not on "runtime"

for( auto iter : m_column_name_pos)
for (const auto& iter : m_column_name_pos)
{
if (!strcmp(iter.first.c_str(), n))
{
Expand Down

0 comments on commit 0f15a1b

Please sign in to comment.