diff --git a/bytecode/src/bytecode.rs b/bytecode/src/bytecode.rs index 85ec43a99..778455581 100644 --- a/bytecode/src/bytecode.rs +++ b/bytecode/src/bytecode.rs @@ -93,8 +93,8 @@ impl ConstantBag for BasicBag { /// a codeobject. Also a module has a codeobject. #[derive(Clone, PartialEq, Serialize, Deserialize)] pub struct CodeObject { - pub instructions: Vec, - pub locations: Vec, + pub instructions: Box<[Instruction]>, + pub locations: Box<[Location]>, pub flags: CodeFlags, pub posonlyarg_count: usize, // Number of positional-only arguments pub arg_count: usize, @@ -103,15 +103,15 @@ pub struct CodeObject { pub first_line_number: usize, pub obj_name: String, // Name of the object that created this code object pub cell2arg: Option>, - pub constants: Vec, + pub constants: Box<[C]>, #[serde(bound( deserialize = "C::Name: serde::Deserialize<'de>", serialize = "C::Name: serde::Serialize" ))] - pub names: Vec, - pub varnames: Vec, - pub cellvars: Vec, - pub freevars: Vec, + pub names: Box<[C::Name]>, + pub varnames: Box<[C::Name]>, + pub cellvars: Box<[C::Name]>, + pub freevars: Box<[C::Name]>, } bitflags! { @@ -129,12 +129,6 @@ bitflags! { } } -impl Default for CodeFlags { - fn default() -> Self { - Self::NEW_LOCALS - } -} - impl CodeFlags { pub const NAME_MAPPING: &'static [(&'static str, CodeFlags)] = &[ ("GENERATOR", CodeFlags::IS_GENERATOR), @@ -542,8 +536,8 @@ impl CodeObject { obj_name: String, ) -> Self { CodeObject { - instructions: Vec::new(), - locations: Vec::new(), + instructions: Box::new([]), + locations: Box::new([]), flags, posonlyarg_count, arg_count, @@ -552,11 +546,11 @@ impl CodeObject { first_line_number, obj_name, cell2arg: None, - constants: Vec::new(), - names: Vec::new(), - varnames: Vec::new(), - cellvars: Vec::new(), - freevars: Vec::new(), + constants: Box::new([]), + names: Box::new([]), + varnames: Box::new([]), + cellvars: Box::new([]), + freevars: Box::new([]), } } @@ -593,7 +587,7 @@ impl CodeObject { pub fn label_targets(&self) -> BTreeSet