Fix inconsistent position calculations by romainmenke · Pull Request #1980 · postcss/postcss

fixes: #1979


Benchmarks:

[16:51:26] Running suite Preprocessors [/Users/romainmenke/projects/postcss-benchmark/preprocessors.js]...

PostCSS sync:      29 ms  (1.0 times faster)
Next PostCSS sync: 29 ms  (1.0 times faster)
PostCSS:           30 ms
Next PostCSS:      31 ms  (1.0 times slower)

...

[16:52:19] Running suite Parsers [/Users/romainmenke/projects/postcss-benchmark/parsers.js]...

PostCSS:      13 ms
Next PostCSS: 13 ms (1.0 times slower)

...

[16:54:02] Running suite Linters [/Users/romainmenke/projects/postcss-benchmark/linters.js]...

Next PostCSS: 207 ms (1.1 times faster)
PostCSS:      219 ms

...

[16:54:14] Running suite Sourcemaps [/Users/romainmenke/projects/postcss-benchmark/sourcemaps.js]...

Next PostCSS: 67 ms (1.0 times faster)
PostCSS:      67 ms

Stylelint even seems to run a bit faster after this update.

I assume that calling String.prototype.slice is noticeably faster than recursively calling Node.prototype.toString() and serializing all nodes.