perf: reduce memory allocations
This also changes `widget::column::with_children` and `widget::row::with_children` to take an `impl IntoIterator` instead of a `Vec`, like the `iced` variants of these functions do. This shouldn't be a breaking change since passing in a `Vec` will still compile and function exactly as before. (Using `iced::widget::Column::from_vec` or `iced::widget::Row::from_vec` isn't possible, since the elements of the `Vec` aren't checked, so the size of the resulting `Column` or `Row` won't adapt to the size of its children. Perhaps a new function could be added to mirror `iced`'s?)
This commit is contained in:
parent
840ef21e4d
commit
bd438a8581
20 changed files with 83 additions and 88 deletions
|
|
@ -170,11 +170,10 @@ impl Config {
|
|||
.map(|x| x.join("COSMIC").join(&path));
|
||||
|
||||
// Get libcosmic user configuration directory
|
||||
let cosmic_user_path = dirs::config_dir()
|
||||
.ok_or(Error::NoConfigDirectory)?
|
||||
.join("cosmic");
|
||||
let mut user_path = dirs::config_dir().ok_or(Error::NoConfigDirectory)?;
|
||||
user_path.push("cosmic");
|
||||
user_path.push(path);
|
||||
|
||||
let user_path = cosmic_user_path.join(path);
|
||||
// Create new configuration directory if not found.
|
||||
fs::create_dir_all(&user_path)?;
|
||||
|
||||
|
|
@ -190,9 +189,9 @@ impl Config {
|
|||
// Look for [name]/v[version]
|
||||
let path = sanitize_name(name)?.join(format!("v{version}"));
|
||||
|
||||
let cosmic_user_path = custom_path.join("cosmic");
|
||||
|
||||
let user_path = cosmic_user_path.join(path);
|
||||
let mut user_path = custom_path;
|
||||
user_path.push("cosmic");
|
||||
user_path.push(path);
|
||||
// Create new configuration directory if not found.
|
||||
fs::create_dir_all(&user_path)?;
|
||||
|
||||
|
|
@ -213,11 +212,9 @@ impl Config {
|
|||
let path = sanitize_name(name)?.join(format!("v{}", version));
|
||||
|
||||
// Get libcosmic user state directory
|
||||
let cosmic_user_path = dirs::state_dir()
|
||||
.ok_or(Error::NoConfigDirectory)?
|
||||
.join("cosmic");
|
||||
|
||||
let user_path = cosmic_user_path.join(path);
|
||||
let mut user_path = dirs::state_dir().ok_or(Error::NoConfigDirectory)?;
|
||||
user_path.push("cosmic");
|
||||
user_path.push(path);
|
||||
// Create new state directory if not found.
|
||||
fs::create_dir_all(&user_path)?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue