Skip to content

Commit

Permalink
fix: remove unused code and use less memory
Browse files Browse the repository at this point in the history
  • Loading branch information
yasonk committed Nov 21, 2024
1 parent 2099676 commit c7e0f29
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
10 changes: 2 additions & 8 deletions core/src/mast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub use node::{
BasicBlockNode, CallNode, DynNode, ExternalNode, JoinNode, LoopNode, MastNode, OpBatch,
OperationOrDecorator, SplitNode, OP_BATCH_SIZE, OP_GROUP_SIZE,
};
use winter_utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable};
use winter_utils::{ByteWriter, DeserializationError, Serializable};

use crate::{Decorator, DecoratorList, Operation};

Expand Down Expand Up @@ -532,7 +532,7 @@ impl MastNodeId {
) -> Result<Self, DeserializationError> {
let node_id: u32 = node_id.try_into().map_err(|_| {
DeserializationError::InvalidValue(format!(
"Invalid node id '{node_id}' while deserializing"
"node id '{node_id}' does not fit into a u32"
))
})?;
MastNodeId::from_u32_safe(node_id, mast_forest)
Expand Down Expand Up @@ -675,12 +675,6 @@ impl Serializable for DecoratorId {
}
}

impl Deserializable for DecoratorId {
fn read_from<R: ByteReader>(source: &mut R) -> Result<Self, DeserializationError> {
Ok(DecoratorId::new_unchecked(source.read()?))
}
}

// MAST FOREST ERROR
// ================================================================================================

Expand Down
7 changes: 3 additions & 4 deletions core/src/mast/serialization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,14 @@ impl Deserializable for MastForest {
// Reading Decorators
let decorator_data: Vec<u8> = Deserializable::read_from(source)?;
let string_table: StringTable = Deserializable::read_from(source)?;
let decorator_infos: Vec<DecoratorInfo> =
decorator_infos_iter(source, decorator_count)
.collect::<Result<Vec<DecoratorInfo>, DeserializationError>>()?;
let decorator_infos = decorator_infos_iter(source, decorator_count);

// Constructing MastForest
let mut mast_forest = {
let mut mast_forest = MastForest::new();

for decorator_info in decorator_infos {
let decorator_info = decorator_info?;
let decorator =
decorator_info.try_into_decorator(&string_table, &decorator_data)?;

Expand Down Expand Up @@ -243,7 +242,7 @@ impl Deserializable for MastForest {
},
other => {
return Err(DeserializationError::InvalidValue(format!(
"Expected mast node with id {node_id} to be a basic block, found {other:?}"
"expected mast node with id {node_id} to be a basic block, found {other:?}"
)))
},
}
Expand Down

0 comments on commit c7e0f29

Please sign in to comment.