refactor: shrink SBuiltinFuncDefinition to reduce binary size by 17MB…#35322
refactor: shrink SBuiltinFuncDefinition to reduce binary size by 17MB…#35322guanshengliang wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reduces the memory footprint of builtin function metadata by shrinking the parameter-pattern arrays in SFunctionParaInfo, aiming to reduce per-executable binary size.
Changes:
- Replace the previous
MAX_FUNC_PARA_NUMsizing with separate limits for pattern count and pattern-entry count. - Reduce
MAX_FUNC_PARA_FIXED_VALUE_NUMfrom 16 to 8. - Update
SFunctionParaInfo::inputParaInfodimensions to match the new sizing macros.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #define MAX_FUNC_PARA_PATTERN_NUM 2 | ||
| #define MAX_FUNC_INPUT_PARA_NUM 8 | ||
| #define MAX_FUNC_PARA_FIXED_VALUE_NUM 8 |
There was a problem hiding this comment.
Code Review
This pull request refactors function parameter limits in builtins.h by replacing the generic MAX_FUNC_PARA_NUM with more specific constants, MAX_FUNC_PARA_PATTERN_NUM and MAX_FUNC_INPUT_PARA_NUM, and reducing the value of MAX_FUNC_PARA_FIXED_VALUE_NUM. The SFunctionParaInfo struct was updated accordingly to use these new dimensions. Review feedback suggests documenting the rationale behind these specific constant values to improve code maintainability.
| #define MAX_FUNC_PARA_PATTERN_NUM 2 | ||
| #define MAX_FUNC_INPUT_PARA_NUM 8 | ||
| #define MAX_FUNC_PARA_FIXED_VALUE_NUM 8 |
There was a problem hiding this comment.
These new macros act as magic numbers. To improve maintainability, please add comments explaining why these specific values were chosen. This context will be valuable for anyone modifying this code in the future.
| #define MAX_FUNC_PARA_PATTERN_NUM 2 | |
| #define MAX_FUNC_INPUT_PARA_NUM 8 | |
| #define MAX_FUNC_PARA_FIXED_VALUE_NUM 8 | |
| #define MAX_FUNC_PARA_PATTERN_NUM 2 // Max parameter patterns per function. Currently 1 is used, 2 allows for future extension. | |
| #define MAX_FUNC_INPUT_PARA_NUM 8 // Max parameter descriptors per pattern. `_irate_partial` uses 4. | |
| #define MAX_FUNC_PARA_FIXED_VALUE_NUM 8 // Max fixed values for a parameter. `week` function uses 8. |
… per executable
Description
Issue(s)
Checklist
Please check the items in the checklist if applicable.