From e896668147fa7897fd5224d7d593f0dcd79173eb Mon Sep 17 00:00:00 2001 From: Nikhil Benesch Date: Tue, 15 Dec 2015 22:42:07 -0500 Subject: [PATCH] Someone please show me a better way to do this --- kvrow.hh | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/kvrow.hh b/kvrow.hh index e0205a5..6c722cf 100644 --- a/kvrow.hh +++ b/kvrow.hh @@ -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(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_; @@ -337,15 +329,7 @@ void query::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(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++;