Simplify `frame_split_size` (#4067)
Simplify `frame_split_size` (#4067)

* Drop 2nd check of `frame` in `frame_split_size`

As we already check `nbytes` and `return`ed if it was `<= n`, we already
know `nbytes(frame) > n`. So there is no need to check it again. Thus we
get rid of this second check.

* Store `nbytes(frame)` in `frame_split_size`

To avoid calling `nbytes(frame)` repeatedly, just store the result as a
variable and access that.

* Assign other computed values in `frame_split_size`

Should also make it a bit clearer what is going on in this code.

* Run `black` on `distributed/protocol/utils.py`

* Always use `memoryview` in `frame_split_size`

As slicing a `memoryview` is free (it just views the underlying data)
and it is able to easily access `itemsize`, just always use
`memoryview`. This keeps `frame_split_size` performing in a reasonable
way. Also simplifies the code a bit.

* Get `memoryview` of `frame` to start

* Skip assigning `itemsize`

This is fast and easy to access from `memoryview` and we only use it as
part of computing the next two variables. So just skip assigning it and
use this `memoryview` property directly.
dask/distributed,dask/distributed,dask/distributed,dask/distributed