Skip to content

Commit 8b88d02

Browse files
committed
substreams: Avoid a clone when constructing the EntityKey
1 parent 019fc4f commit 8b88d02

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

chain/substreams/src/trigger.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,8 @@ where
219219
}
220220
}
221221
};
222-
let key = EntityKey {
223-
entity_type: entity_type.clone(),
224-
entity_id: entity_id.clone().into(),
225-
causality_region: CausalityRegion::ONCHAIN, // Substreams don't currently support offchain data
226-
};
227-
let mut data: HashMap<Word, Value> = HashMap::from_iter(vec![]);
228222

223+
let mut data: HashMap<Word, Value> = HashMap::from_iter(vec![]);
229224
for field in entity_change.fields.iter() {
230225
let new_value: &codec::value::Typed = match &field.new_value {
231226
Some(codec::Value {
@@ -236,7 +231,7 @@ where
236231

237232
let value: Value = decode_value(new_value)?;
238233
*data
239-
.entry(Word::from(field.name.clone()))
234+
.entry(Word::from(field.name.as_str()))
240235
.or_insert(Value::Null) = value;
241236
}
242237

@@ -252,6 +247,12 @@ where
252247
logger,
253248
);
254249

250+
let key = EntityKey {
251+
entity_type: entity_type,
252+
entity_id: Word::from(entity_id),
253+
causality_region: CausalityRegion::ONCHAIN, // Substreams don't currently support offchain data
254+
};
255+
255256
let id = state.entity_cache.schema.id_value(&key)?;
256257
data.insert(Word::from("id"), id);
257258

0 commit comments

Comments
 (0)