Skip to content

Commit

Permalink
Someone please show me a better way to do this
Browse files Browse the repository at this point in the history
  • Loading branch information
benesch committed Dec 16, 2015
1 parent 586d14c commit 54b7242
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions kvrow.hh
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,7 @@ class query_json_scanner {
bool visit_value(Str key, R* value, threadinfo& ti) {
if (row_is_marker(value))
return true;
// NB the `key` is not stable! We must save space for it.
while (q_.scankeypos_ + key.length() > q_.scankey_.length()) {
q_.scankey_ = lcdf::String::make_uninitialized(q_.scankey_.length() ? q_.scankey_.length() * 2 : 1024);
q_.scankeypos_ = 0;
}
memcpy(const_cast<char*>(q_.scankey_.data() + q_.scankeypos_),
key.data(), key.length());
request_.push_back(q_.scankey_.substr(q_.scankeypos_, key.length()));
q_.scankeypos_ += key.length();
request_.push_back(*(new lcdf::String(key)));
request_.push_back(lcdf::Json());
q_.emit_fields1(value, request_.back(), ti);
--nleft_;
Expand Down Expand Up @@ -337,15 +329,7 @@ void query<R>::run_iscan(T& table, Json& request, threadinfo& ti) {
R* value = it->second;
if (row_is_marker(value))
break;
// NB the `key` is not stable! We must save space for it.
while (scankeypos_ + key.length() > scankey_.length()) {
scankey_ = lcdf::String::make_uninitialized(scankey_.length() ? scankey_.length() * 2 : 1024);
scankeypos_ = 0;
}
memcpy(const_cast<char*>(scankey_.data() + scankeypos_),
key.data(), key.length());
request.push_back(scankey_.substr(scankeypos_, key.length()));
scankeypos_ += key.length();
request.push_back(*(new lcdf::String(key)));
request.push_back(lcdf::Json());
emit_fields1(value, request.back(), ti);
it++;
Expand Down

0 comments on commit 54b7242

Please sign in to comment.