feat(container/garray): enhance generic array implements#4482
feat(container/garray): enhance generic array implements#4482
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the array implementation to make TArray a standalone generic array type rather than a wrapper. Other array types (Array, StrArray, IntArray) now embed TArray instead of maintaining their own implementations.
Key Changes:
- Converted
TArrayfrom wrapper to full implementation with direct generic type support - Refactored
StrArray,IntArray, andArrayto embedTArray[T]with lazy initialization - Updated test assertions to reflect corrected array state after operations
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| container/garray/garray_normal_t.go | Converted TArray from wrapper to standalone implementation with full generic support and direct array operations |
| container/garray/garray_normal_str.go | Refactored to embed TArray[string] with lazy initialization pattern |
| container/garray/garray_normal_int.go | Refactored to embed TArray[int] with lazy initialization pattern |
| container/garray/garray_normal_any.go | Refactored to embed TArray[any] with lazy initialization pattern |
| container/garray/garray_z_unit_normal_t_test.go | Updated test assertions to match corrected array behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
container/garray/garray_normal_str.go:115
- Direct access to
a.arraywill cause a nil pointer dereference. The fieldarraybelongs toTArray, notStrArray. Should bea.TArray.arrayor the sorting logic should be delegated toTArray.SortFunc.
a.mu.Lock()
defer a.mu.Unlock()
if len(reverse) > 0 && reverse[0] {
sort.Slice(a.array, func(i, j int) bool {
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This reverts commit 7e896ed.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This reverts commit 772d7bd.
Remove the t array of wrapper array. Now it's a real one. Other normal array will base on it.