Implemented functions for FlatList module to correspond to Array module#10
Implemented functions for FlatList module to correspond to Array module#10rokklobster wants to merge 19 commits intofsprojects:developfrom
FlatList module to correspond to Array module#10Conversation
- conversions - plain distinct based on distinctBy - scans and folds - signatures simplifications - fix unzip3 - sorting/comparing
There was a problem hiding this comment.
В целом хорошо.
Сравни как в модуле List там кажись все фкнции принимают строго list но не seq.
Соответственно тебе нужно будет добавить аннотации
There was a problem hiding this comment.
Ну раз raiseOrReturn уже устанавливает такое ограничение, то супер
- remove excessive `get` - add initialization with value (and use in `create`/`replicate`) - use `Seq` in majority of functions - simplify `fill` - fix signatures
- change `countBy`, `indexed`, `iter2` to use `Seq` - fix distinctBy (remove excessive arg + use `raiseOrReturn`)
FlatList module to correspond to Array module
| [<CompiledName("Build")>] | ||
| let inline build f = | ||
| let builder = builder() | ||
| f builder | ||
| moveFromBuilder builder | ||
|
|
||
| [<CompiledName("Update")>] | ||
| let inline update f list = | ||
| let builder = toBuilder list | ||
| f builder | ||
| moveFromBuilder builder |
There was a problem hiding this comment.
А что эти функции делают?
There was a problem hiding this comment.
Позволяют выполнить действие над билдером. Использований в модуле нет, думаю удалить их
|
Надо будет все вызовы переделать на вызовы отсюда У них это единственный класс, который имеет свой LINQ. |
|
Потому, что вместо проверки на null там проверяется, есть ли внутри ImmutableArray сам массив. |
| @@ -16,49 +19,75 @@ module FlatList = | |||
| let inline internal checkNotDefault argName (list : FlatList<'T>) = | |||
| if list.IsDefault then invalidArg argName "Uninstantiated ImmutableArray/FlatList" | |||
| let inline internal check (list : FlatList<'T>) = checkNotDefault (nameof list) list | |||
There was a problem hiding this comment.
Получается самый быстрый вариант – это дёрнуть IsEmpty и выбросить
https://github.com/dotnet/runtime/blob/54c717a4ed822f46a23893479b8d4398596c041d/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Minimal.cs#L157
И получится то же, что они делают. Тогда не нужно использовать их LINQ обёртку
| if list.IsDefault then invalidArg argName "Uninstantiated ImmutableArray/FlatList" | ||
| let inline internal check (list : FlatList<'T>) = checkNotDefault (nameof list) list | ||
| let inline internal checkEmpty (list : FlatList<_>) = check list; if list.Length = 0 then invalidArg (nameof list) "Source is empty" else () | ||
| let inline internal raiseOrReturn list = check list; list |
There was a problem hiding this comment.
Тут наверное надо переименовать будет на checkAndReturn чтобы было в едином стиле
|
Посмотрел ещё раз https://github.com/dotnet/runtime/blob/main/src/libraries/System.Collections.Immutable/src/System/Linq/ImmutableArrayExtensions.cs |
|
При чём, наверное, именно для этой коллекции стоит отойти от правила возвращать такой же тип при преобразовании, а возвращать |
- rename checkAndReturn - use ImmutableArrayExtensions in some places - remove ofSeq calls
No description provided.