mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-21 21:42:23 -05:00
Update the bins buffer capacity
This commit is contained in:
parent
beb7b24e8e
commit
84a818dbda
2 changed files with 6 additions and 3 deletions
|
@ -3,6 +3,9 @@ use std::path::Path;
|
|||
|
||||
use crate::info_file::ExerciseInfo;
|
||||
|
||||
/// Initial capacity of the bins buffer.
|
||||
pub const BINS_BUFFER_CAPACITY: usize = 1 << 14;
|
||||
|
||||
/// Return the start and end index of the content of the list `bin = […]`.
|
||||
/// bin = [xxxxxxxxxxxxxxxxx]
|
||||
/// |start_ind |
|
||||
|
@ -70,7 +73,7 @@ pub fn updated_cargo_toml(
|
|||
) -> Result<Vec<u8>> {
|
||||
let (bins_start_ind, bins_end_ind) = bins_start_end_ind(current_cargo_toml)?;
|
||||
|
||||
let mut updated_cargo_toml = Vec::with_capacity(1 << 13);
|
||||
let mut updated_cargo_toml = Vec::with_capacity(BINS_BUFFER_CAPACITY);
|
||||
updated_cargo_toml.extend_from_slice(current_cargo_toml[..bins_start_ind].as_bytes());
|
||||
append_bins(
|
||||
&mut updated_cargo_toml,
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
cargo_toml::{append_bins, bins_start_end_ind},
|
||||
cargo_toml::{append_bins, bins_start_end_ind, BINS_BUFFER_CAPACITY},
|
||||
info_file::{ExerciseInfo, InfoFile},
|
||||
CURRENT_FORMAT_VERSION, DEBUG_PROFILE,
|
||||
};
|
||||
|
@ -145,7 +145,7 @@ fn check_cargo_toml(
|
|||
let (bins_start_ind, bins_end_ind) = bins_start_end_ind(current_cargo_toml)?;
|
||||
|
||||
let old_bins = ¤t_cargo_toml.as_bytes()[bins_start_ind..bins_end_ind];
|
||||
let mut new_bins = Vec::with_capacity(1 << 13);
|
||||
let mut new_bins = Vec::with_capacity(BINS_BUFFER_CAPACITY);
|
||||
append_bins(&mut new_bins, exercise_infos, exercise_path_prefix);
|
||||
|
||||
if old_bins != new_bins {
|
||||
|
|
Loading…
Reference in a new issue