Skip to content

Commit 0f15a1b

Browse files
committed
S3select: replacing a "naked loop" with std::copy_n
... and fixing some extra copying Signed-off-by: Ronen Friedman <[email protected]>
1 parent 81f5e17 commit 0f15a1b

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

include/s3select_oper.h

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <list>
77
#include <map>
88
#include <vector>
9+
#include <algorithm>
910
#include <string.h>
1011
#include <math.h>
1112

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

230-
void update(std::vector<char*>& tokens, size_t num_of_tokens)
231+
void update(const std::vector<char*>& tokens, size_t num_of_tokens)
231232
{
232-
size_t i=0;
233-
for(auto s : tokens)
234-
{
235-
if (i>=num_of_tokens)
236-
{
237-
break;
238-
}
239-
240-
m_columns[i++] = s;
241-
}
242-
m_upper_bound = i;
243-
233+
std::copy_n(tokens.begin(), num_of_tokens, m_columns.begin());
234+
m_upper_bound = num_of_tokens;
244235
}
245236

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

250-
for( auto iter : m_column_name_pos)
241+
for (const auto& iter : m_column_name_pos)
251242
{
252243
if (!strcmp(iter.first.c_str(), n))
253244
{

0 commit comments

Comments
 (0)