Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit caefb8e

Browse files
committed
apply review
1 parent be05bc1 commit caefb8e

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

vm/src/stdlib/functools.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ mod _functools {
244244
let mut final_kwargs = IndexMap::new();
245245

246246
// Add keywords from self.keywords
247-
for (key, value) in inner.keywords.clone() {
247+
for (key, value) in &*inner.keywords {
248248
let key_str = key
249249
.downcast::<crate::builtins::PyStr>()
250250
.map_err(|_| vm.new_type_error("keywords must be strings".to_owned()))?;
@@ -291,27 +291,24 @@ mod _functools {
291291
let class_name = zelf.class().name();
292292
let module = zelf.class().module(vm);
293293

294-
// Check if this is a subclass by comparing with the base partial type
295-
let is_subclass = !zelf.class().is(PyPartial::class(&vm.ctx));
296-
297-
let qualified_name = if !is_subclass {
294+
let qualified_name = if zelf.class().is(PyPartial::class(&vm.ctx)) {
298295
// For the base partial class, always use functools.partial
299-
"functools.partial".to_string()
296+
"functools.partial".to_owned()
300297
} else {
301298
// For subclasses, check if they're defined in __main__ or test modules
302299
match module.downcast::<crate::builtins::PyStr>() {
303300
Ok(module_str) => {
304301
let module_name = module_str.as_str();
305302
match module_name {
306-
"builtins" | "" | "__main__" => class_name.to_string(),
303+
"builtins" | "" | "__main__" => class_name.to_owned(),
307304
name if name.starts_with("test.") || name == "test" => {
308305
// For test modules, just use the class name without module prefix
309-
class_name.to_string()
306+
class_name.to_owned()
310307
}
311308
_ => format!("{}.{}", module_name, class_name),
312309
}
313310
}
314-
Err(_) => class_name.to_string(),
311+
Err(_) => class_name.to_owned(),
315312
}
316313
};
317314

0 commit comments

Comments
 (0)