Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Span deserialization. #4595

Merged
merged 1 commit into from
Dec 20, 2023
Merged

Improve Span deserialization. #4595

merged 1 commit into from
Dec 20, 2023

Conversation

ilyalesokhin-starkware
Copy link
Contributor

@ilyalesokhin-starkware ilyalesokhin-starkware commented Dec 18, 2023

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.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @ilyalesokhin-starkware)


corelib/src/array.cairo line 147 at r1 (raw file):

        serialized = serialized.slice(length, serialized.len() - length);
        Option::Some(Span { snapshot: res })
    }

you probably need to make this impl have a negative param - and have a specific impl for Span

Code quote:

        let length = *serialized.pop_front()?;;
        let res = serialized.slice(0, length);
        serialized = serialized.slice(length, serialized.len() - length);
        Option::Some(Span { snapshot: res })
    }

@ilyalesokhin-starkware ilyalesokhin-starkware force-pushed the ilya/span_serde branch 2 times, most recently from 042428f to aa2c22d Compare December 20, 2023 12:07
Copy link
Contributor Author

@ilyalesokhin-starkware ilyalesokhin-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @orizi)


corelib/src/array.cairo line 147 at r1 (raw file):

Previously, orizi wrote…

you probably need to make this impl have a negative param - and have a specific impl for Span

Done.

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.

Reviewed 1 of 3 files at r2.
Reviewable status: 1 of 3 files reviewed, 3 unresolved discussions (waiting on @ilyalesokhin-starkware)


corelib/src/array.cairo line 7 at r2 (raw file):

use core::option::OptionTrait;
use core::serde::Serde;
use core::metaprogramming::{TypeEqual, TypeEqualImpl};

Suggestion:

use core::metaprogramming::TypeEqual;

corelib/src/lib.cairo line 355 at r2 (raw file):

// Metaprogramming.
pub mod metaprogramming;

Suggestion:

// Metaprogramming.
mod metaprogramming;

corelib/src/metaprogramming.cairo line 5 at r2 (raw file):

pub trait TypeEqual<S, T> {}

pub impl TypeEqualImpl<T> of TypeEqual<T, T>;

Suggestion:

/// A trait that can be used to disable implementations based on the types of the generic args.
/// Assumes that `TypeEqualImpl` is the only implementation of this trait.
pub trait TypeEqual<S, T> {}

impl TypeEqualImpl<T> of TypeEqual<T, T>;

@ilyalesokhin-starkware
Copy link
Contributor Author

corelib/src/lib.cairo line 355 at r2 (raw file):

// Metaprogramming.
pub mod metaprogramming;

why?
A user might want to use TypeEqual

@ilyalesokhin-starkware
Copy link
Contributor Author

corelib/src/metaprogramming.cairo line 5 at r2 (raw file):

pub trait TypeEqual<S, T> {}

pub impl TypeEqualImpl<T> of TypeEqual<T, T>;

what about the idea that only pub impls can be infered?

Copy link
Contributor Author

@ilyalesokhin-starkware ilyalesokhin-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 3 files reviewed, 3 unresolved discussions (waiting on @orizi)


corelib/src/array.cairo line 7 at r2 (raw file):

use core::option::OptionTrait;
use core::serde::Serde;
use core::metaprogramming::{TypeEqual, TypeEqualImpl};

Done.

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.

Reviewed 1 of 3 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ilyalesokhin-starkware)


corelib/src/metaprogramming.cairo line 5 at r2 (raw file):

Previously, ilyalesokhin-starkware wrote…

what about the idea that only pub impls can be infered?

we have decided against it.

Copy link
Contributor Author

@ilyalesokhin-starkware ilyalesokhin-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 3 files reviewed, 2 unresolved discussions (waiting on @orizi)


corelib/src/metaprogramming.cairo line 5 at r2 (raw file):

Previously, orizi wrote…

we have decided against it.

Done.

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.

:lgtm:

Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ilyalesokhin-starkware)

@ilyalesokhin-starkware ilyalesokhin-starkware added this pull request to the merge queue Dec 20, 2023
Merged via the queue into main with commit 8862b29 Dec 20, 2023
38 checks passed
@orizi orizi deleted the ilya/span_serde branch December 21, 2023 09:12
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.

2 participants