refactor normalizeArray, improve performance

[test code](https://gist.github.com/dead-horse/ae3d6d34b6ec44d8d6ed)

before:

```
normalize simple path: 694ms
resolve simple path: 2662ms
normalize path contains .: 685ms
resolve path contains .: 2672ms
normalize path contains ..: 1002ms
resolve path contains ..: 3271ms
```

after:

```
normalize simple path: 325ms
resolve simple path: 909ms
normalize path contains .: 319ms
resolve path contains .: 896ms
normalize path contains ..: 434ms
resolve path contains ..: 1128ms
```