Skip to content

Conversation

@Fibonacci747
Copy link
Contributor

Summary

  • Fetch zero_sized property before box_ty() call
  • Remove second .clone() by moving ty directly into OutputVarInfo
  • Reduces unnecessary allocations in boxing signature specialization

Type of change

  • Performance improvement

Why is this change needed?

The original code had two .clone() calls on ty:

  1. One for box_ty()
    /// Helper for getting the `Box<T>` type.
    pub fn box_ty(
    context: &dyn SignatureSpecializationContext,
    ty: ConcreteTypeId,
    ) -> Result<ConcreteTypeId, SpecializationError> {
    context.get_wrapped_concrete_type(BoxType::id(), ty)
    }
    consumption
  2. One for OutputVarInfo.ty before borrow in get_type_info()

@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orizi made 1 comment.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @Fibonacci747).


crates/cairo-lang-sierra/src/extensions/modules/boxing.rs line 127 at r1 (raw file):

                    OutputVarReferenceInfo::Deferred(DeferredOutputKind::Generic)
                },
            }],

Suggestion:

        let ref_info = if context.get_type_info(&ty)?.zero_sized {
            OutputVarReferenceInfo::ZeroSized
        } else {
            OutputVarReferenceInfo::Deferred(DeferredOutputKind::Generic)
        };
        Ok(LibfuncSignature::new_non_branch(
            vec![box_ty(context, ty.clone())?],
            vec![OutputVarInfo { ty, ref_info }],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants