From 69a80872e17118a9d50b9b1eb7b3929b340d8c13 Mon Sep 17 00:00:00 2001 From: Folkert Date: Thu, 25 Nov 2021 19:46:05 +0100 Subject: [PATCH 1/3] rename start -> index --- compiler/types/src/subs.rs | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/compiler/types/src/subs.rs b/compiler/types/src/subs.rs index 7682290a2a..50d8227d10 100644 --- a/compiler/types/src/subs.rs +++ b/compiler/types/src/subs.rs @@ -80,7 +80,7 @@ pub struct SubsSlice { /// An index into the Vec of subs pub struct SubsIndex { - pub start: u32, + pub index: u32, _marker: std::marker::PhantomData, } @@ -91,13 +91,13 @@ impl std::ops::Index> for Subs { type Output = Variable; fn index(&self, index: SubsIndex) -> &Self::Output { - &self.variables[index.start as usize] + &self.variables[index.index as usize] } } impl std::ops::IndexMut> for Subs { fn index_mut(&mut self, index: SubsIndex) -> &mut Self::Output { - &mut self.variables[index.start as usize] + &mut self.variables[index.index as usize] } } @@ -105,7 +105,7 @@ impl std::ops::Index> for Subs { type Output = Lowercase; fn index(&self, index: SubsIndex) -> &Self::Output { - &self.field_names[index.start as usize] + &self.field_names[index.index as usize] } } @@ -113,19 +113,19 @@ impl std::ops::Index> for Subs { type Output = TagName; fn index(&self, index: SubsIndex) -> &Self::Output { - &self.tag_names[index.start as usize] + &self.tag_names[index.index as usize] } } impl std::ops::IndexMut> for Subs { fn index_mut(&mut self, index: SubsIndex) -> &mut Self::Output { - &mut self.tag_names[index.start as usize] + &mut self.tag_names[index.index as usize] } } impl std::ops::IndexMut> for Subs { fn index_mut(&mut self, index: SubsIndex) -> &mut Self::Output { - &mut self.field_names[index.start as usize] + &mut self.field_names[index.index as usize] } } @@ -133,13 +133,13 @@ impl std::ops::Index>> for Subs { type Output = RecordField<()>; fn index(&self, index: SubsIndex>) -> &Self::Output { - &self.record_fields[index.start as usize] + &self.record_fields[index.index as usize] } } impl std::ops::IndexMut>> for Subs { fn index_mut(&mut self, index: SubsIndex>) -> &mut Self::Output { - &mut self.record_fields[index.start as usize] + &mut self.record_fields[index.index as usize] } } @@ -147,13 +147,13 @@ impl std::ops::Index> for Subs { type Output = VariableSubsSlice; fn index(&self, index: SubsIndex) -> &Self::Output { - &self.variable_slices[index.start as usize] + &self.variable_slices[index.index as usize] } } impl std::ops::IndexMut> for Subs { fn index_mut(&mut self, index: SubsIndex) -> &mut Self::Output { - &mut self.variable_slices[index.start as usize] + &mut self.variable_slices[index.index as usize] } } @@ -165,7 +165,7 @@ impl std::fmt::Debug for SubsIndex { f, "SubsIndex<{}>({})", std::any::type_name::(), - self.start + self.index ) } } @@ -187,7 +187,7 @@ impl Copy for SubsIndex {} impl Clone for SubsIndex { fn clone(&self) -> Self { Self { - start: self.start, + index: self.index, _marker: self._marker, } } @@ -271,7 +271,7 @@ impl SubsSlice { impl SubsIndex { pub fn new(start: u32) -> Self { Self { - start, + index: start, _marker: std::marker::PhantomData, } } @@ -290,7 +290,7 @@ impl IntoIterator for SubsSlice { fn u32_to_index(i: u32) -> SubsIndex { SubsIndex { - start: i, + index: i, _marker: std::marker::PhantomData, } } @@ -1643,7 +1643,7 @@ impl UnionTags { pub fn from_tag_name_index(index: SubsIndex) -> Self { Self::from_slices( - SubsSlice::new(index.start, 1), + SubsSlice::new(index.index, 1), SubsSlice::new(0, 1), // the first variablesubsslice is the empty slice ) } @@ -2843,7 +2843,7 @@ fn restore_help(subs: &mut Subs, initial: Variable) { } TagUnion(tags, ext_var) => { for slice_index in tags.variables() { - let slice = variable_slices[slice_index.start as usize]; + let slice = variable_slices[slice_index.index as usize]; stack.extend(var_slice(slice)); } @@ -2855,7 +2855,7 @@ fn restore_help(subs: &mut Subs, initial: Variable) { RecursiveTagUnion(rec_var, tags, ext_var) => { for slice_index in tags.variables() { - let slice = variable_slices[slice_index.start as usize]; + let slice = variable_slices[slice_index.index as usize]; stack.extend(var_slice(slice)); } @@ -3064,7 +3064,7 @@ impl StorageSubs { offsets: &StorageSubsOffsets, mut tag_name: SubsIndex, ) -> SubsIndex { - tag_name.start += offsets.tag_names; + tag_name.index += offsets.tag_names; tag_name } From 612f8686528c1d57954174241ff37fc1d85b0a06 Mon Sep 17 00:00:00 2001 From: Folkert Date: Thu, 25 Nov 2021 20:29:34 +0100 Subject: [PATCH 2/3] make VariableSubsSlice an alias --- cli/src/repl/eval.rs | 12 ++--- compiler/solve/src/solve.rs | 12 ++--- compiler/types/src/pretty_print.rs | 26 +++------ compiler/types/src/solved_types.rs | 4 +- compiler/types/src/subs.rs | 85 ++++++++---------------------- compiler/types/src/types.rs | 9 ++-- compiler/unify/src/unify.rs | 10 ++-- 7 files changed, 50 insertions(+), 108 deletions(-) diff --git a/cli/src/repl/eval.rs b/cli/src/repl/eval.rs index 2b01c0e582..b9780389fc 100644 --- a/cli/src/repl/eval.rs +++ b/cli/src/repl/eval.rs @@ -647,8 +647,8 @@ fn unpack_single_element_tag_union(subs: &Subs, tags: UnionTags) -> (&TagName, & let (tag_name_index, payload_vars_index) = tags.iter_all().next().unwrap(); let tag_name = &subs[tag_name_index]; - let subs_slice = subs[payload_vars_index].as_subs_slice(); - let payload_vars = subs.get_subs_slice(*subs_slice); + let subs_slice = subs[payload_vars_index]; + let payload_vars = subs.get_subs_slice(subs_slice); (tag_name, payload_vars) } @@ -661,14 +661,14 @@ fn unpack_two_element_tag_union( let (tag_name_index, payload_vars_index) = it.next().unwrap(); let tag_name1 = &subs[tag_name_index]; - let subs_slice = subs[payload_vars_index].as_subs_slice(); - let payload_vars1 = subs.get_subs_slice(*subs_slice); + let subs_slice = subs[payload_vars_index]; + let payload_vars1 = subs.get_subs_slice(subs_slice); let (tag_name_index, payload_vars_index) = it.next().unwrap(); let tag_name2 = &subs[tag_name_index]; - let subs_slice = subs[payload_vars_index].as_subs_slice(); - let payload_vars2 = subs.get_subs_slice(*subs_slice); + let subs_slice = subs[payload_vars_index]; + let payload_vars2 = subs.get_subs_slice(subs_slice); (tag_name1, payload_vars1, tag_name2, payload_vars2) } diff --git a/compiler/solve/src/solve.rs b/compiler/solve/src/solve.rs index 634bb9a6ba..51d1035b80 100644 --- a/compiler/solve/src/solve.rs +++ b/compiler/solve/src/solve.rs @@ -906,7 +906,7 @@ fn alias_to_var<'a>( } AliasVariables { - variables_start: new_variables.slice.start, + variables_start: new_variables.start, type_variables_len: type_arguments.len() as _, all_variables_len: length as _, } @@ -1501,7 +1501,7 @@ fn instantiate_rigids_help(subs: &mut Subs, max_rank: Rank, initial: Variable) { macro_rules! var_slice { ($variable_subs_slice:expr) => {{ let slice = $variable_subs_slice; - &subs.variables[slice.slice.start as usize..][..slice.slice.length as usize] + &subs.variables[slice.indices()] }}; } @@ -1570,7 +1570,7 @@ fn instantiate_rigids_help(subs: &mut Subs, max_rank: Rank, initial: Variable) { let ext_var = *ext_var; for slice_index in tags.variables() { - let slice = subs.variable_slices[slice_index.start as usize]; + let slice = subs.variable_slices[slice_index.index as usize]; stack.extend(var_slice!(slice)); } @@ -1586,7 +1586,7 @@ fn instantiate_rigids_help(subs: &mut Subs, max_rank: Rank, initial: Variable) { let rec_var = *rec_var; for slice_index in tags.variables() { - let slice = subs.variable_slices[slice_index.start as usize]; + let slice = subs.variable_slices[slice_index.index as usize]; stack.extend(var_slice!(slice)); } @@ -1736,7 +1736,7 @@ fn deep_copy_var_help( RecordFields { length: fields.length, field_names_start: fields.field_names_start, - variables_start: new_variables.slice.start, + variables_start: new_variables.start, field_types_start: fields.field_types_start, } }; @@ -1844,7 +1844,7 @@ fn deep_copy_var_help( } let new_arguments = AliasVariables { - variables_start: new_variables.slice.start, + variables_start: new_variables.start, ..arguments }; diff --git a/compiler/types/src/pretty_print.rs b/compiler/types/src/pretty_print.rs index dbfed01a18..9592b7b7af 100644 --- a/compiler/types/src/pretty_print.rs +++ b/compiler/types/src/pretty_print.rs @@ -504,24 +504,14 @@ fn write_flat_type(env: &Env, flat_type: &FlatType, subs: &Subs, buf: &mut Strin use crate::subs::FlatType::*; match flat_type { - Apply(symbol, args) => write_apply( - env, - *symbol, - subs.get_subs_slice(*args.as_subs_slice()), - subs, - buf, - parens, - ), + Apply(symbol, args) => { + write_apply(env, *symbol, subs.get_subs_slice(*args), subs, buf, parens) + } EmptyRecord => buf.push_str(EMPTY_RECORD), EmptyTagUnion => buf.push_str(EMPTY_TAG_UNION), - Func(args, _closure, ret) => write_fn( - env, - subs.get_subs_slice(*args.as_subs_slice()), - *ret, - subs, - buf, - parens, - ), + Func(args, _closure, ret) => { + write_fn(env, subs.get_subs_slice(*args), *ret, subs, buf, parens) + } Record(fields, ext_var) => { use crate::types::{gather_fields, RecordStructure}; @@ -640,7 +630,7 @@ pub fn chase_ext_tag_union<'a>( Content::Structure(TagUnion(tags, ext_var)) => { for (name_index, slice_index) in tags.iter_all() { let subs_slice = subs[slice_index]; - let slice = subs.get_subs_slice(*subs_slice.as_subs_slice()); + let slice = subs.get_subs_slice(subs_slice); let tag_name = subs[name_index].clone(); fields.push((tag_name, slice.to_vec())); @@ -652,7 +642,7 @@ pub fn chase_ext_tag_union<'a>( Content::Structure(RecursiveTagUnion(_, tags, ext_var)) => { for (name_index, slice_index) in tags.iter_all() { let subs_slice = subs[slice_index]; - let slice = subs.get_subs_slice(*subs_slice.as_subs_slice()); + let slice = subs.get_subs_slice(subs_slice); let tag_name = subs[name_index].clone(); fields.push((tag_name, slice.to_vec())); diff --git a/compiler/types/src/solved_types.rs b/compiler/types/src/solved_types.rs index 3fe67edf2f..b742b52898 100644 --- a/compiler/types/src/solved_types.rs +++ b/compiler/types/src/solved_types.rs @@ -299,7 +299,7 @@ impl SolvedType { Apply(symbol, args) => { let mut new_args = Vec::with_capacity(args.len()); - for var in subs.get_subs_slice(*args.as_subs_slice()) { + for var in subs.get_subs_slice(*args) { new_args.push(Self::from_var_help(subs, recursion_vars, *var)); } @@ -308,7 +308,7 @@ impl SolvedType { Func(args, closure, ret) => { let mut new_args = Vec::with_capacity(args.len()); - for var in subs.get_subs_slice(*args.as_subs_slice()) { + for var in subs.get_subs_slice(*args) { new_args.push(Self::from_var_help(subs, recursion_vars, *var)); } diff --git a/compiler/types/src/subs.rs b/compiler/types/src/subs.rs index 50d8227d10..f4d95fa0c3 100644 --- a/compiler/types/src/subs.rs +++ b/compiler/types/src/subs.rs @@ -367,7 +367,7 @@ fn subs_fmt_content(this: &Content, subs: &Subs, f: &mut fmt::Formatter) -> fmt: } => write!(f, "Recursion({:?}, {:?})", structure, opt_name), Content::Structure(flat_type) => subs_fmt_flat_type(flat_type, subs, f), Content::Alias(name, arguments, actual) => { - let slice = subs.get_subs_slice(*arguments.variables().as_subs_slice()); + let slice = subs.get_subs_slice(arguments.variables()); write!(f, "Alias({:?}, {:?}, {:?})", name, slice, actual) } @@ -386,12 +386,12 @@ impl<'a> fmt::Debug for SubsFmtFlatType<'a> { fn subs_fmt_flat_type(this: &FlatType, subs: &Subs, f: &mut fmt::Formatter) -> fmt::Result { match this { FlatType::Apply(name, arguments) => { - let slice = subs.get_subs_slice(*arguments.as_subs_slice()); + let slice = subs.get_subs_slice(*arguments); write!(f, "Apply({:?}, {:?})", name, slice) } FlatType::Func(arguments, lambda_set, result) => { - let slice = subs.get_subs_slice(*arguments.as_subs_slice()); + let slice = subs.get_subs_slice(*arguments); write!(f, "Func({:?}, {:?}, {:?})", slice, lambda_set, result) } FlatType::Record(fields, ext) => { @@ -1425,9 +1425,7 @@ pub struct AliasVariables { impl AliasVariables { pub const fn variables(&self) -> VariableSubsSlice { - VariableSubsSlice { - slice: SubsSlice::new(self.variables_start, self.all_variables_len), - } + SubsSlice::new(self.variables_start, self.all_variables_len) } pub const fn len(&self) -> usize { @@ -1555,34 +1553,9 @@ pub enum Builtin { EmptyRecord, } -#[derive(Clone, Copy, Debug, Default)] -pub struct VariableSubsSlice { - pub slice: SubsSlice, -} +pub type VariableSubsSlice = SubsSlice; impl VariableSubsSlice { - pub fn len(&self) -> usize { - self.slice.len() - } - - pub fn is_empty(&self) -> bool { - self.len() == 0 - } - - pub fn as_subs_slice(&self) -> &SubsSlice { - &self.slice - } - - pub fn new(start: u32, length: u16) -> Self { - Self { - slice: SubsSlice::new(start, length), - } - } - - pub fn indices(&self) -> std::ops::Range { - self.slice.indices() - } - /// Reserve space for `length` variables in the subs.variables array /// /// This is useful when we know how many variables e.g. a loop will produce, @@ -1614,16 +1587,6 @@ impl VariableSubsSlice { } } -impl IntoIterator for VariableSubsSlice { - type Item = SubsIndex; - - type IntoIter = as IntoIterator>::IntoIter; - - fn into_iter(self) -> Self::IntoIter { - self.slice.into_iter() - } -} - #[derive(Clone, Copy, Debug, Default)] pub struct UnionTags { length: u16, @@ -1637,7 +1600,7 @@ impl UnionTags { return false; } - let slice = subs.variable_slices[self.variables_start as usize].slice; + let slice = subs.variable_slices[self.variables_start as usize]; slice.length == 1 } @@ -1764,7 +1727,9 @@ impl UnionTags { ) -> impl Iterator + 'a { let (it, _) = crate::types::gather_tags_unsorted_iter(subs, *self, ext); - it.map(move |(label, slice)| (label, subs.get_subs_slice(*slice.as_subs_slice()))) + let f = move |(label, slice): (_, SubsSlice)| (label, subs.get_subs_slice(slice)); + + it.map(f) } pub fn unsorted_iterator_and_ext<'a>( @@ -1774,10 +1739,9 @@ impl UnionTags { ) -> (impl Iterator + 'a, Variable) { let (it, ext) = crate::types::gather_tags_unsorted_iter(subs, *self, ext); - ( - it.map(move |(label, slice)| (label, subs.get_subs_slice(*slice.as_subs_slice()))), - ext, - ) + let f = move |(label, slice): (_, SubsSlice)| (label, subs.get_subs_slice(slice)); + + (it.map(f), ext) } #[inline(always)] @@ -1792,7 +1756,7 @@ impl UnionTags { let tag_name: &TagName = &subs[i1]; let subs_slice = subs[i2]; - let slice = subs.get_subs_slice(*subs_slice.as_subs_slice()); + let slice = subs.get_subs_slice(subs_slice); (tag_name.clone(), slice) })), @@ -1903,9 +1867,7 @@ impl RecordFields { } pub const fn variables(&self) -> VariableSubsSlice { - let slice = SubsSlice::new(self.variables_start, self.length); - - VariableSubsSlice { slice } + SubsSlice::new(self.variables_start, self.length) } pub fn iter_variables(&self) -> impl Iterator> { @@ -2081,16 +2043,13 @@ fn occurs( new_seen.insert(root_var); match flat_type { - Apply(_, args) => short_circuit( - subs, - root_var, - &new_seen, - subs.get_subs_slice(*args.as_subs_slice()).iter(), - ), + Apply(_, args) => { + short_circuit(subs, root_var, &new_seen, subs.get_subs_slice(*args).iter()) + } Func(arg_vars, closure_var, ret_var) => { let it = once(ret_var) .chain(once(closure_var)) - .chain(subs.get_subs_slice(*arg_vars.as_subs_slice()).iter()); + .chain(subs.get_subs_slice(*arg_vars).iter()); short_circuit(subs, root_var, &new_seen, it) } Record(vars_by_field, ext_var) => { @@ -2798,10 +2757,8 @@ fn restore_help(subs: &mut Subs, initial: Variable) { let variable_slices = &subs.variable_slices; let variables = &subs.variables; - let var_slice = |variable_subs_slice: VariableSubsSlice| { - &variables[variable_subs_slice.slice.start as usize..] - [..variable_subs_slice.slice.length as usize] - }; + let var_slice = + |variable_subs_slice: VariableSubsSlice| &variables[variable_subs_slice.indices()]; while let Some(var) = stack.pop() { let desc = &mut subs.utable.probe_value_ref_mut(var).value; @@ -3082,7 +3039,7 @@ impl StorageSubs { offsets: &StorageSubsOffsets, mut slice: VariableSubsSlice, ) -> VariableSubsSlice { - slice.slice.start += offsets.variables; + slice.start += offsets.variables; slice } diff --git a/compiler/types/src/types.rs b/compiler/types/src/types.rs index 04130e2484..27927f41e5 100644 --- a/compiler/types/src/types.rs +++ b/compiler/types/src/types.rs @@ -1765,7 +1765,7 @@ pub fn gather_tags_slices( let (it, ext) = gather_tags_unsorted_iter(subs, other_fields, var); let mut result: Vec<_> = it - .map(|(ref_label, field)| (ref_label.clone(), field)) + .map(|(ref_label, field): (_, VariableSubsSlice)| (ref_label.clone(), field)) .collect(); result.sort_by(|(a, _), (b, _)| a.cmp(b)); @@ -1777,11 +1777,8 @@ pub fn gather_tags(subs: &Subs, other_fields: UnionTags, var: Variable) -> TagUn let (it, ext) = gather_tags_unsorted_iter(subs, other_fields, var); let mut result: Vec<_> = it - .map(|(ref_label, field)| { - ( - ref_label.clone(), - subs.get_subs_slice(*field.as_subs_slice()), - ) + .map(|(ref_label, field): (_, VariableSubsSlice)| { + (ref_label.clone(), subs.get_subs_slice(field)) }) .collect(); diff --git a/compiler/unify/src/unify.rs b/compiler/unify/src/unify.rs index ff8f51966e..6a8c4f05ec 100644 --- a/compiler/unify/src/unify.rs +++ b/compiler/unify/src/unify.rs @@ -842,7 +842,7 @@ fn unify_shared_tags_new( all_fields = merge_sorted( all_fields, other1.into_iter().map(|(field_name, subs_slice)| { - let vec = subs.get_subs_slice(*subs_slice.as_subs_slice()).to_vec(); + let vec = subs.get_subs_slice(subs_slice).to_vec(); (field_name, vec) }), @@ -851,7 +851,7 @@ fn unify_shared_tags_new( all_fields = merge_sorted( all_fields, other2.into_iter().map(|(field_name, subs_slice)| { - let vec = subs.get_subs_slice(*subs_slice.as_subs_slice()).to_vec(); + let vec = subs.get_subs_slice(subs_slice).to_vec(); (field_name, vec) }), @@ -969,8 +969,7 @@ fn unify_flat_type( } (Apply(l_symbol, l_args), Apply(r_symbol, r_args)) if l_symbol == r_symbol => { - let problems = - unify_zip_slices(subs, pool, *l_args.as_subs_slice(), *r_args.as_subs_slice()); + let problems = unify_zip_slices(subs, pool, *l_args, *r_args); if problems.is_empty() { merge(subs, ctx, Structure(Apply(*r_symbol, *r_args))) @@ -981,8 +980,7 @@ fn unify_flat_type( (Func(l_args, l_closure, l_ret), Func(r_args, r_closure, r_ret)) if l_args.len() == r_args.len() => { - let arg_problems = - unify_zip_slices(subs, pool, *l_args.as_subs_slice(), *r_args.as_subs_slice()); + let arg_problems = unify_zip_slices(subs, pool, *l_args, *r_args); let ret_problems = unify_pool(subs, pool, *l_ret, *r_ret); let closure_problems = unify_pool(subs, pool, *l_closure, *r_closure); From b4f21930bb4f3eff6d54dac5fe4c78b223bc8dd9 Mon Sep 17 00:00:00 2001 From: Folkert Date: Thu, 25 Nov 2021 20:49:44 +0100 Subject: [PATCH 3/3] cleanup --- compiler/solve/src/solve.rs | 16 +++++++++------- compiler/types/src/subs.rs | 14 +++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/compiler/solve/src/solve.rs b/compiler/solve/src/solve.rs index 51d1035b80..5c1263218d 100644 --- a/compiler/solve/src/solve.rs +++ b/compiler/solve/src/solve.rs @@ -1175,23 +1175,25 @@ fn check_for_infinite_type( }, ); - let mut new_tags = Vec::with_capacity(tags.len()); + let new_variable_slices = SubsSlice::reserve_variable_slices(subs, tags.len()); - for (name_index, slice_index) in tags.iter_all() { + let it = new_variable_slices.indices().zip(tags.iter_all()); + for (variable_slice_index, (_, slice_index)) in it { let slice = subs[slice_index]; - let mut new_vars = Vec::new(); - for var_index in slice { + let new_variables = VariableSubsSlice::reserve_into_subs(subs, slice.len()); + for (target_index, var_index) in new_variables.indices().zip(slice) { let var = subs[var_index]; - new_vars.push(subs.explicit_substitute(recursive, rec_var, var)); + subs.variables[target_index] = + subs.explicit_substitute(recursive, rec_var, var); } - new_tags.push((subs[name_index].clone(), new_vars)); + subs.variable_slices[variable_slice_index] = new_variables; } let new_ext_var = subs.explicit_substitute(recursive, rec_var, ext_var); - let new_tags = UnionTags::insert_into_subs(subs, new_tags); + let new_tags = UnionTags::from_slices(tags.tag_names(), new_variable_slices); let flat_type = FlatType::RecursiveTagUnion(rec_var, new_tags, new_ext_var); diff --git a/compiler/types/src/subs.rs b/compiler/types/src/subs.rs index f4d95fa0c3..8569d0771e 100644 --- a/compiler/types/src/subs.rs +++ b/compiler/types/src/subs.rs @@ -1983,9 +1983,11 @@ impl RecordFields { SubsIndex>, ), > { - let range1 = self.field_names_start..self.field_names_start + self.length as u32; - let range2 = self.variables_start..self.variables_start + self.length as u32; - let range3 = self.field_types_start..self.field_types_start + self.length as u32; + let helper = |start| start..(start + self.length as u32); + + let range1 = helper(self.field_names_start); + let range2 = helper(self.variables_start); + let range3 = helper(self.field_types_start); let it = range1 .into_iter() @@ -3247,8 +3249,7 @@ fn deep_copy_var_to_help<'a>( let new_tag_names = { let tag_names = tags.tag_names(); - let slice = &source.tag_names[tag_names.start as usize..] - [..tag_names.length as usize]; + let slice = &source.tag_names[tag_names.indices()]; let start = target.tag_names.len() as u32; let length = tag_names.len() as u16; @@ -3305,8 +3306,7 @@ fn deep_copy_var_to_help<'a>( let new_tag_names = { let tag_names = tags.tag_names(); - let slice = &source.tag_names[tag_names.start as usize..] - [..tag_names.length as usize]; + let slice = &source.tag_names[tag_names.indices()]; let start = target.tag_names.len() as u32; let length = tag_names.len() as u16;