Replace magic number with DEFAULT_MAX_DISCS
This commit is contained in:
parent
d0eecc36c5
commit
f556703baf
1 changed files with 4 additions and 5 deletions
|
|
@ -149,13 +149,12 @@ pub fn build_dest_format_script(disk_id: usize, part_type: &PartitionTableType)
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn build_get_disk_script(disk_nums: Option<Vec<&str>>) -> String {
|
pub fn build_get_disk_script(disk_nums: Option<Vec<&str>>) -> String {
|
||||||
let capacity = DEFAULT_MAX_DISKS * 3 + 1;
|
|
||||||
let script: String;
|
let script: String;
|
||||||
|
|
||||||
// Get disk and partition details
|
// Get disk and partition details
|
||||||
if let Some(disks) = disk_nums {
|
if let Some(disks) = disk_nums {
|
||||||
// (Slower case)
|
// (Slower case)
|
||||||
let mut script_parts = Vec::with_capacity(capacity);
|
let mut script_parts = Vec::with_capacity(DEFAULT_MAX_DISKS * 3 + 1);
|
||||||
|
|
||||||
// Get list of disks
|
// Get list of disks
|
||||||
script_parts.push(String::from("list disk"));
|
script_parts.push(String::from("list disk"));
|
||||||
|
|
@ -171,7 +170,7 @@ pub fn build_get_disk_script(disk_nums: Option<Vec<&str>>) -> String {
|
||||||
script = script_parts.join("\n");
|
script = script_parts.join("\n");
|
||||||
} else {
|
} else {
|
||||||
// (Best case)
|
// (Best case)
|
||||||
let mut script_parts = Vec::with_capacity(capacity);
|
let mut script_parts = Vec::with_capacity(DEFAULT_MAX_DISKS + 1);
|
||||||
|
|
||||||
// Get list of disks
|
// Get list of disks
|
||||||
script_parts.push("list disk");
|
script_parts.push("list disk");
|
||||||
|
|
@ -181,9 +180,9 @@ pub fn build_get_disk_script(disk_nums: Option<Vec<&str>>) -> String {
|
||||||
script_parts.push("detail disk");
|
script_parts.push("detail disk");
|
||||||
script_parts.push("list partition");
|
script_parts.push("list partition");
|
||||||
|
|
||||||
// Limit to 8 disks (if there's more the manual "worst" case will be used)
|
// Limit to DEFAULT_MAX_DISKS (if there's more the manual "worst" case will be used)
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
while i < 8 {
|
while i < DEFAULT_MAX_DISKS {
|
||||||
script_parts.push("select disk next");
|
script_parts.push("select disk next");
|
||||||
script_parts.push("detail disk");
|
script_parts.push("detail disk");
|
||||||
script_parts.push("list partition");
|
script_parts.push("list partition");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue