Thank you for your comments and advice.
I moved down `array.length` and now `insertInPlace` uses `uninitializedArray` to allocate buffer.