Skip to content

Commit 68945ff

Browse files
committed
Avoid cloning endpoint multiple times
1 parent 7ebe2d9 commit 68945ff

File tree

1 file changed

+7
-9
lines changed
  • lib/executor/src/executors

1 file changed

+7
-9
lines changed

lib/executor/src/executors/map.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,19 +194,17 @@ impl SubgraphExecutorMap {
194194
)
195195
})?;
196196
let endpoint_str = match endpoint_result.as_str() {
197-
Some(s) => s.to_string(),
198-
None => {
199-
return Err(SubgraphExecutorError::EndpointExpressionWrongType(
200-
subgraph_name.to_string(),
201-
));
202-
}
203-
};
197+
Some(s) => Ok(s),
198+
None => Err(SubgraphExecutorError::EndpointExpressionWrongType(
199+
subgraph_name.to_string(),
200+
)),
201+
}?;
204202

205203
// Check if an executor for this endpoint already exists.
206204
let existing_executor = self
207205
.executors_by_subgraph
208206
.get(subgraph_name)
209-
.and_then(|endpoints| endpoints.get(&endpoint_str).map(|e| e.clone()));
207+
.and_then(|endpoints| endpoints.get(endpoint_str.as_ref()).map(|e| e.clone()));
210208

211209
if let Some(executor) = existing_executor {
212210
return Ok(Some(executor));
@@ -219,7 +217,7 @@ impl SubgraphExecutorMap {
219217
.executors_by_subgraph
220218
.get(subgraph_name)
221219
.expect("Executor was just registered, should be present");
222-
return Ok(endpoints.get(&endpoint_str).map(|e| e.clone()));
220+
return Ok(endpoints.get(endpoint_str.as_ref()).map(|e| e.clone()));
223221
}
224222

225223
Ok(None)

0 commit comments

Comments
 (0)