The GitHub Actions job "Sync Files" on fory.git/main has failed.
Run started by GitHub user chaokunyang (triggered by chaokunyang).

Head commit for run:
69aa5f248bfe19796538c6f04d29fd79e6cc5a5a / Shawn Yang <[email protected]>
feat(rust): rewrite fory derive macro for smaller and faster generated code 
using compile-time fields sort algorithm (#2749)

## Why?

<!-- Describe the purpose of this PR. -->

## What does this PR do?

- designed a new fields sort algorithm which is friendly to compile-time
languages, the compile-time languages can use this new fields sort
algorithm to generate serialize code at compile time
-  rewrite fory rust derive macro for smaller and faster generated code

Given struct:
```rust
#[derive(ForyObject, Debug, PartialEq)]
struct Person1 {
    f1: Color1,
    f2: Color1,
    // skip
    f3: Color2,
    f5: Vec<Color1>,
    f6: Option<Color1>,
    f7: Option<Color1>,
    f8: Color1,
    last: i8,
}
```

For following struct, this PR generates code:

```rust
fn fory_write_data(
    &self,
    fory: &fory_core::fory::Fory,
    context: &mut fory_core::resolver::context::WriteContext,
    is_field: bool,
) {
    fory_core::serializer::write_ref_info_data::<
        i8,
    >(&self.last, fory, context, true, true, false);
    fory_core::serializer::write_ref_info_data::<
        Vec<Color1>,
    >(&self.f5, fory, context, true, false, false);
    fory_core::serializer::write_ref_info_data::<
        Color1,
    >(&self.f1, fory, context, true, false, false);
    fory_core::serializer::write_ref_info_data::<
        Color1,
    >(&self.f2, fory, context, true, false, false);
    fory_core::serializer::write_ref_info_data::<
        Color2,
    >(&self.f3, fory, context, true, false, false);
    fory_core::serializer::write_ref_info_data::<
        Option<Color1>,
    >(&self.f6, fory, context, true, false, false);
    fory_core::serializer::write_ref_info_data::<
        Option<Color1>,
    >(&self.f7, fory, context, true, false, false);
    fory_core::serializer::write_ref_info_data::<
        Color1,
    >(&self.f8, fory, context, true, false, false);
}
fn fory_read_data(
    fory: &fory_core::fory::Fory,
    context: &mut fory_core::resolver::context::ReadContext,
    is_field: bool,
) -> Result<Self, fory_core::error::Error> {
    let _last = fory_core::serializer::read_ref_info_data::<
        i8,
    >(fory, context, true, true, false)?;
    let _f5 = fory_core::serializer::read_ref_info_data::<
        Vec<Color1>,
    >(fory, context, true, false, false)?;
    let _f1 = fory_core::serializer::read_ref_info_data::<
        Color1,
    >(fory, context, true, false, false)?;
    let _f2 = fory_core::serializer::read_ref_info_data::<
        Color1,
    >(fory, context, true, false, false)?;
    let _f3 = fory_core::serializer::read_ref_info_data::<
        Color2,
    >(fory, context, true, false, false)?;
    let _f6 = fory_core::serializer::read_ref_info_data::<
        Option<Color1>,
    >(fory, context, true, false, false)?;
    let _f7 = fory_core::serializer::read_ref_info_data::<
        Option<Color1>,
    >(fory, context, true, false, false)?;
    let _f8 = fory_core::serializer::read_ref_info_data::<
        Color1,
    >(fory, context, true, false, false)?;
    Ok(Self {
        last: _last,
        f5: _f5,
        f1: _f1,
        f2: _f2,
        f3: _f3,
        f6: _f6,
        f7: _f7,
        f8: _f8,
    })
}
```

This PR also reverts #2724 since it generats lots of inefficient code
and bloat code size

## Related issues

<!--
Is there any related issue? If this PR closes them you say say
fix/closes:

- #xxxx0
- #xxxx1
- Fixes #xxxx2
-->

## Does this PR introduce any user-facing change?

<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/fory/issues/new/choose) describing the
need to do so and update the document if necessary.

Delete section if not applicable.
-->

- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?

## Benchmark

<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.

Delete section if not applicable.
-->

Report URL: https://github.com/apache/fory/actions/runs/18446984974

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to