Copilot commented on code in PR #229:
URL: 
https://github.com/apache/cloudstack-cloudmonkey/pull/229#discussion_r4258253726


##########
cli/completer.go:
##########
@@ -224,6 +225,53 @@ func pluralizeNoun(noun string) string {
        }
 }
 
+func mapFieldsFromDescription(description string) []string {
+       fields := []string{}
+       seen := make(map[string]bool)

Review Comment:
   For a pure set, `map[string]struct{}` is the idiomatic choice in Go and 
avoids storing an extra boolean per entry. This is a small improvement but 
helps keep intent clear.



##########
cli/completer.go:
##########
@@ -224,6 +225,53 @@ func pluralizeNoun(noun string) string {
        }
 }
 
+func mapFieldsFromDescription(description string) []string {
+       fields := []string{}
+       seen := make(map[string]bool)
+
+       re := regexp.MustCompile(`([A-Za-z0-9_-]+\[\d+\]\.[A-Za-z0-9_.:-]+)=`)

Review Comment:
   Compiling the regexp on every call to `mapFieldsFromDescription` adds 
unnecessary overhead (this runs during interactive completion). Consider 
compiling the regexp once at package scope (e.g., `var mapFieldRe = 
regexp.MustCompile(...)`) and reusing it inside the function.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to