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

feat: generate faststr for thrift string #73

Merged
merged 1 commit into from
Dec 7, 2022

Conversation

Millione
Copy link
Member

@Millione Millione commented Dec 7, 2022

Motivation

struct A {
    1: required string faststr,
    2: required string string(pilota.rust_type = "string"),
}

Generated:

pub struct A {
    pub faststr: ::pilota::FastStr,
    pub string: ::std::string::String,
}

pilota/src/thrift/binary.rs Outdated Show resolved Hide resolved
fn read_faststr(&mut self) -> Result<FastStr, Error> {
let len = self.trans.read_i32()? as usize;
let bytes = self.trans.split_to(len);
if len >= ZERO_COPY_THRESHOLD {
Copy link
Member

Choose a reason for hiding this comment

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

这里有必要么?是不是直接全部走 zero copy 就行了?

Copy link
Member Author

@Millione Millione Dec 7, 2022

Choose a reason for hiding this comment

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

小string的情况下还是Arc<str>更好吧

@PureWhiteWu PureWhiteWu merged commit d2e3759 into cloudwego:main Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants