PERF: improve perf of index iteration (GH7683)

closes #7683

``PeriodIndex`` creation is still in python space, not much help

```
-------------------------------------------------------------------------------
Test name                                    | head[ms] | base[ms] |  ratio   |
-------------------------------------------------------------------------------
timeseries_iter_datetimeindex_preexit        |  12.7254 | 3657.9890 |   0.0035 |
timeseries_iter_datetimeindex                | 679.8913 | 3726.6284 |   0.1824 |
timeseries_iter_periodindex_preexit          |  69.0370 |  62.8881 |   1.0978 |
timeseries_iter_periodindex                  | 6941.9633 | 6024.2947 |   1.1523 |
-------------------------------------------------------------------------------
Test name                                    | head[ms] | base[ms] |  ratio   |
-------------------------------------------------------------------------------

Ratio < 1.0 means the target commit is faster then the baseline.
Seed used: 1234

Target [142718e] : PERF: DatetimeIndex.__iter__ now uses ints_to_pydatetime with boxing
Base   [f9493ea] : Merge pull request #7713 from jorisvandenbossche/doc-fixes3

DOC: fix doc build warnings
```
a lot dup codes under this if/else clause. combine them?