Skip to content

optimize(tool): optimize fastcodec->frugal replacement #1696

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

Merged

Conversation

HeyJavaBean
Copy link
Member

@HeyJavaBean HeyJavaBean commented Feb 13, 2025

What type of PR is this?

optimize

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

optimize(tool): 优化了生成工具关于 frugal 替换参数的实现逻辑

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
Previously: gen-frugal was used to decide whether to replace the implementation of structs with frugal based on annotations, and -frugal-struct xxx was used to pass the struct name when executing a command.

Now: Only the -frugal-struct parameter is retained, with different inputs achieving different effects:

  1. -frugal-struct @ALL: Replaces all structs named fastCodec with frugal implementation.
  2. -frugal-struct @auto: Replaces structs with annotations (equivalent to the previous gen-frugal parameter).
  3. -frugal-struct xxxname: Specifies a specific struct, can be specified multiple times.

And also some template optimizations:

  • implement BLength() by frugal EncodedSize.
  • remove fastReadField, fastWriteField, fieldLength function because it's no longer used after frugal replacement.

zh(optional):
把 -gen-frugal 和 -frugal-struct 合并了

之前:有 gen-frugal 来决定是否根据注解给结构体替换 frugal 实现,也有 -frugal-struct xxx 执行命令行时传入结构体名来替换
现在:只保留 -frugal-struct 参数,不同输入达到不同效果:

  1. -frugal-struct @ALL:给所有结构体 fastCodec 都替换为 frugal 实现
  2. -frugal-struct @auto: 给有注解的结构体替换(相当于之前的gen-frugal参数)
  3. -frugal-struct xxxname: 指定具体结构体,可以多次指定,和之前一样

模板上也有一些改动:

  1. BLength 也改为用 frugal EncodedSize 来替换实现了
  2. 开启 frugal 替换后,不再生成 fastReadField, fastWriteField, fieldLength,因为用不到了

(Optional) Which issue(s) this PR fixes:

(optional) The PR that updates user documentation:

@HeyJavaBean HeyJavaBean requested review from a team as code owners February 13, 2025 06:53
@HeyJavaBean HeyJavaBean force-pushed the optimize/frugal_struct_argument branch from 0d8d5b5 to 225e075 Compare February 13, 2025 07:00
@HeyJavaBean HeyJavaBean force-pushed the optimize/frugal_struct_argument branch from 225e075 to 23675c5 Compare February 13, 2025 07:15
@HeyJavaBean HeyJavaBean changed the title optimize(tool): optimize the impelemtation of fastcodec->frugal replacement argument optimize(tool): optimize fastcodec->frugal replacement Feb 13, 2025
@HeyJavaBean HeyJavaBean force-pushed the optimize/frugal_struct_argument branch from 13b39e5 to 2187b0a Compare February 13, 2025 07:52
@HeyJavaBean HeyJavaBean merged commit ebac2b0 into cloudwego:develop Feb 13, 2025
19 checks passed
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.

3 participants