PERF: better perf on _ensure_data in core/algorithms, helping perf of unique, duplicated, factorize
xref #16043 

```
   before     after       ratio
  [6f525eec] [3cc49f80]
+   82.43μs   115.72μs      1.40  timeseries.DatetimeIndex.time_unique
+  120.41ms   161.89ms      1.34  frame_methods.frame_duplicated.time_frame_duplicated_wide
+    7.78ms    10.43ms      1.34  groupby.GroupBySuite.time_unique('int', 100)
+   12.13ms    15.91ms      1.31  groupby.GroupBySuite.time_unique('float', 100)
+  707.18ms   916.55ms      1.30  groupby.GroupBySuite.time_unique('int', 10000)
+     1.24s      1.49s      1.20  groupby.GroupBySuite.time_unique('float', 10000)
+  400.17μs   448.59μs      1.12  groupby.GroupBySuite.time_nunique('float', 100)
-    8.64ms     2.46ms      0.28  period.Algorithms.time_drop_duplicates_pseries
```

so lowers the diff with 0.19.2 a bit.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=h1) Report
> Merging [#16046](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/d16cce89521c84fcb9c7b7bb2e95629a6fe7acb7?src=pr&el=desc) will **increase** coverage by `0.02%`.
> The diff coverage is `98.57%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/16046/graphs/tree.svg?height=150&width=650&src=pr&token=eZ4WkYLtcO)](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #16046      +/-   ##
==========================================
+ Coverage   90.76%   90.79%   +0.02%     
==========================================
  Files         155      156       +1     
  Lines       50484    50534      +50     
==========================================
+ Hits        45824    45883      +59     
+ Misses       4660     4651       -9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.56% <98.57%> (+0.02%)` | :arrow_up: |
| #single | `40.44% <65.71%> (+0.02%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/algorithms.py](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYWxnb3JpdGhtcy5weQ==) | `94.41% <100%> (-0.05%)` | :arrow_down: |
| [pandas/core/dtypes/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbW1vbi5weQ==) | `93.63% <98%> (+0.36%)` | :arrow_up: |
| [pandas/core/dtypes/cast.py](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Nhc3QucHk=) | `86.89% <0%> (-1.37%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `79.63% <0%> (-0.19%)` | :arrow_down: |
| [pandas/compat/pickle\_compat.py](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9waWNrbGVfY29tcGF0LnB5) | `69.51% <0%> (ø)` | :arrow_up: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.19% <0%> (ø)` | :arrow_up: |
| [pandas/core/api.py](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXBpLnB5) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/tseries/api.py](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvYXBpLnB5) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/tseries/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvcGVyaW9kLnB5) | | |
| [pandas/tseries/tdi.py](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvdGRpLnB5) | | |
| ... and [18 more](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=footer). Last update [d16cce8...48986f1](https://codecov.io/gh/pandas-dev/pandas/pull/16046?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
