Slice: Optimize slice func tools (#9)

IntSlice and StringSlice: preallocate memory up front for output slice.
Instead returning a error throw a panic because most likely it's a
programming error.
Contain: rename slice to iterableType and add default case for type
mismatches
This commit is contained in:
donutloop authored and GitHub committed 2021-12-31 10:15:38 +08:00
1 parent 051f20caef
commit 147c1625b5
2 files changed
+32 -24

No files matched your search

+2 -4
View File
@@ -237,10 +237,8 @@ func TestIntSlice(t *testing.T) {
}
func intSlice(t *testing.T, test interface{}, expected []int) {
res, err := IntSlice(test)
if err != nil {
t.Error("IntSlice Error: " + err.Error())
}
res := IntSlice(test)
if !reflect.DeepEqual(res, expected) {
utils.LogFailedTestInfo(t, "IntSlice", test, expected, res)
t.FailNow()