As a precondition to
SERVER-55028 that is aimed to improve such function, it is recommendable to further simplify/clarify the auto split vector code.
- Extract the logic to extend the chunk bounds into an independent function
- Extract the minKey == maxKey check into an independent function
- Bring out of from the collection lock scope the code that doesn't require it
- Avoid the confusing part adding/removing minKey to the split vector, but rather simply keep the last split point reference initialized to the first chunk's key
- Better document each unintuitive step/statement
- Simplify code but preserve the original semantic