-
Notifications
You must be signed in to change notification settings - Fork 17
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
WIP - Initial go request builder package #263
Conversation
WalkthroughThe latest updates primarily introduce advanced builders in the Changes
Recent review detailsConfiguration used: CodeRabbit UI Files ignored due to path filters (2)
Files selected for processing (1)
Files skipped from review due to trivial changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
// CallOnAdaptor adds call data for the CallOnAdaptor function to the builder | ||
func (cdb *CellarCallBuilder) CallOnAdaptor(adaptorCall *steward_proto.AdaptorCall) *CellarCallBuilder { | ||
// search functionCalls for type steward_proto.CellarV2_5_FunctionCall_CallOnAdaptor and if | ||
// it already exists, append to CallOnAdaptor.Data instead of creating a new CallOnAdaptor struct | ||
found := false | ||
for _, call := range cdb.functionCalls { | ||
if call.GetCallOnAdaptor() != nil { | ||
found = true | ||
call.GetCallOnAdaptor().Data = append(call.GetCallOnAdaptor().Data, adaptorCall) | ||
break | ||
} | ||
} | ||
|
||
if !found { | ||
cdb.functionCalls = append(cdb.functionCalls, &steward_proto.CellarV2_5_FunctionCall{ | ||
Function: &steward_proto.CellarV2_5_FunctionCall_CallOnAdaptor { | ||
CallOnAdaptor: &steward_proto.CellarV2_5_CallOnAdaptor{ | ||
Data: []*steward_proto.AdaptorCall{adaptorCall}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
return cdb | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optimize the addition of function calls.
The method CallOnAdaptor
checks if a specific type of function call exists before adding a new one. This could be optimized using a map for quicker lookups.
- found := false
- for _, call := range cdb.functionCalls {
- if call.GetCallOnAdaptor() != nil {
- found = true
- call.GetCallOnAdaptor().Data = append(call.GetCallOnAdaptor().Data, adaptorCall)
- break
- }
- }
+ if call, exists := cdb.functionCallMap["CallOnAdaptor"]; exists {
+ call.GetCallOnAdaptor().Data = append(call.GetCallOnAdaptor().Data, adaptorCall)
+ } else {
+ cdb.functionCalls = append(cdb.functionCalls, &steward_proto.CellarV2_5_FunctionCall{
+ Function: &steward_proto.CellarV2_5_FunctionCall_CallOnAdaptor {
+ CallOnAdaptor: &steward_proto.CellarV2_5_CallOnAdaptor{
+ Data: []*steward_proto.AdaptorCall{adaptorCall},
+ },
+ },
+ })
+ }
This change introduces a map to track existing function calls, improving the efficiency of lookups and additions.
Committable suggestion was skipped due to low confidence.
Summary by CodeRabbit
New Features
Bug Fixes
Chores