Skip to content

Commit 508f59d

Browse files
committed
a bit optimized version
1 parent c3c833e commit 508f59d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

packages/cubejs-backend-native/src/node_export.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,15 +510,15 @@ fn debug_js_to_clrepr_to_js(mut cx: FunctionContext) -> JsResult<JsValue> {
510510

511511
fn parse_cubestore_ws_result_message(mut cx: FunctionContext) -> JsResult<JsValue> {
512512
let msg = cx.argument::<JsBuffer>(0)?;
513-
let msg_data = msg.as_slice(&cx);
514-
match parse_cubestore_ws_result(msg_data) {
513+
let msg_data = msg.as_slice(&cx).to_vec();
514+
match parse_cubestore_ws_result(&*msg_data) {
515515
Ok(result) => {
516516
let js_array = JsArray::new(&mut cx, result.len());
517517
for (i, row) in result.into_iter().enumerate() {
518518
let js_row = JsObject::new(&mut cx);
519519
for (key, value) in row.into_iter() {
520-
let js_key = cx.string(&key);
521-
let js_value = cx.string(&value);
520+
let js_key = cx.string(key);
521+
let js_value = cx.string(value);
522522
js_row.set(&mut cx, js_key, js_value)?;
523523
}
524524
js_array.set(&mut cx, i as u32, js_row)?;

rust/cubeorchestrator/src/cubestore_message_parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl std::error::Error for ParseError {}
3030

3131
pub fn parse_cubestore_ws_result(
3232
msg_data: &[u8],
33-
) -> Result<Vec<HashMap<String, String>>, ParseError> {
33+
) -> Result<Vec<HashMap<&str, &str>>, ParseError> {
3434
let http_message =
3535
root_as_http_message(msg_data).map_err(|_| ParseError::FlatBufferError)?;
3636

@@ -57,7 +57,7 @@ pub fn parse_cubestore_ws_result(
5757
if column.is_empty() {
5858
return Err(ParseError::ColumnNameNotDefined);
5959
}
60-
columns.push(column.to_string());
60+
columns.push(column);
6161
}
6262

6363
let result_set_rows = result_set.rows().ok_or(ParseError::EmptyResultSet)?;
@@ -69,7 +69,7 @@ pub fn parse_cubestore_ws_result(
6969

7070
for (i, val) in values.iter().enumerate() {
7171
let value = val.string_value().ok_or(ParseError::ColumnValueMissed)?;
72-
row_obj.insert(columns[i].clone(), value.to_string());
72+
row_obj.insert(columns[i], value);
7373
}
7474

7575
result.push(row_obj);

0 commit comments

Comments
 (0)