mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +08:00
Remove unnecessary string copies (#891)
1. Use string_view instead of string when there is no need for copy. 2. Otherwise move string when possible.
This commit is contained in:
@@ -23,8 +23,7 @@ const std::string& NodeNamer::get_name(const array& x) {
|
||||
letters.push_back('A' + (var_num - 1) % 26);
|
||||
var_num = (var_num - 1) / 26;
|
||||
}
|
||||
std::string name(letters.rbegin(), letters.rend());
|
||||
names.insert({x.id(), name});
|
||||
names.emplace(x.id(), std::string(letters.rbegin(), letters.rend()));
|
||||
|
||||
return get_name(x);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user