Commit 6cb3d7e
authored
refactor: reduce duplication in make_udf_function macro (#18733)
## Which issue does this PR close?
Closes #18669
## Rationale for this change
The `make_udf_function!` macro had significant code duplication between
its two arms. Both arms contained nearly identical 16-line
implementations that only differed in the constructor call.
Additionally, the `$UDF` parameter was unused in the second arm, which
was inefficient.
This refactoring eliminates the duplication by applying a delegation
pattern, where the simpler 2-parameter arm now delegates to the more
complete 3-parameter arm with a default constructor.
## What changes are included in this PR?
- **Reordered macro arms**: The 3-parameter arm (with `$CTOR`) is now
first and contains the full implementation
- **Delegation pattern**: The 2-parameter arm now delegates to the
3-parameter arm by calling `make_udf_function!($UDF, $NAME,
<$UDF>::new)`
- **Parameter type change**: Changed `$CTOR` from `:path` to `:expr` and
wrap the call as `($CTOR)()` for flexibility
- **Fixed unused parameter**: The `$UDF` type parameter is now utilized
in the 2-parameter arm to construct the default constructor path
- **Code reduction**: Reduced the macro from 33 lines to 25 lines by
eliminating duplication
## Are these changes tested?
Yes
## Are there any user-facing changes?
No1 parent ac9bb17 commit 6cb3d7e
1 file changed
+4
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
| 101 | + | |
| 102 | + | |
115 | 103 | | |
116 | 104 | | |
117 | 105 | | |
| |||
0 commit comments