public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Sterz <s.sterz@proxmox.com>
To: Lukas Wagner <l.wagner@proxmox.com>,
	Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Maximiliano Sandoval <m.sandoval@proxmox.com>
Subject: Re: [pve-devel] [PATCH installer] tui: persist disk selection for zfs and btrfs
Date: Tue, 27 Jun 2023 15:59:58 +0200	[thread overview]
Message-ID: <b37ce3e3-ec2c-b351-edef-adb4a8741531@proxmox.com> (raw)
In-Reply-To: <4e6e294b-4e9f-3ee1-413f-eb90e9357031@proxmox.com>

On 27.06.23 15:57, Lukas Wagner wrote:
> 
> 
> On 6/27/23 15:34, Maximiliano Sandoval wrote:
>>>     impl BtrfsBootdiskOptions {
>>> -    pub fn defaults_from(disk: &Disk) -> Self {
>>> +    pub fn defaults_from(disks: &[Disk]) -> Self {
>>> +        let disk = &disks[0];
>>>           Self {
>>>               disk_size: disk.size,
>>> +            selected_disks: (0..disks.len()).collect(),
>>
>> Any reason not to use Vec::with_capacity(disks.len()) here?
>>
> 
> I haven't really examined the rest of the code, but wouldn't that change
> the behavior
> completely? E.g., if `disk.len()` is 3, then
> `(0..disks.len()).collect()` will give you a Vec [0, 1, 2], while
> `Vec::with_capacity(disks.len())` would give you an empty Vec with an
> initial capacity
> of at least 3.
> 
> 

yes. we've already discussed this off list. this is needed here because
otherwise you panic out in `MultiDiskOptionsView::new()` because
`selected_disk` would have a length of zero. the ascending numbers are
needed to have the same initial selection as we currently do.

i'll send a patch with the other nits resolved in a minute.




      reply	other threads:[~2023-06-27 13:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27 12:54 Stefan Sterz
2023-06-27 13:34 ` Maximiliano Sandoval
2023-06-27 13:57   ` Lukas Wagner
2023-06-27 13:59     ` Stefan Sterz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b37ce3e3-ec2c-b351-edef-adb4a8741531@proxmox.com \
    --to=s.sterz@proxmox.com \
    --cc=l.wagner@proxmox.com \
    --cc=m.sandoval@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal