Skip to content

Commit 61e752e

Browse files
Merge pull request #994 from mkurnikov/simplify-with-cloned
Simplify PyFuncArgs get_kwarg/get_optional_kwarg with cloned()
2 parents 59fa46d + 737ec52 commit 61e752e

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

vm/src/function.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,14 @@ impl PyFuncArgs {
8585
}
8686

8787
pub fn get_kwarg(&self, key: &str, default: PyObjectRef) -> PyObjectRef {
88-
if let Some(kwarg_value) = self.kwargs.get(key) {
89-
return kwarg_value.clone();
90-
}
91-
default.clone()
88+
self.kwargs
89+
.get(key)
90+
.cloned()
91+
.unwrap_or_else(|| default.clone())
9292
}
9393

9494
pub fn get_optional_kwarg(&self, key: &str) -> Option<PyObjectRef> {
95-
if let Some(kwarg_value) = self.kwargs.get(key) {
96-
return Some(kwarg_value.clone());
97-
}
98-
None
95+
self.kwargs.get(key).cloned()
9996
}
10097

10198
pub fn get_optional_kwarg_with_type(

0 commit comments

Comments
 (0)