hugolib: Speed up GetPage
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 22 May 2017 22:20:31 +0000 (01:20 +0300)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 23 May 2017 12:18:26 +0000 (15:18 +0300)
commitfbb78b89df8ccef8f0ab26af00aa45d35c1ee2cf
tree67fb115f9c9c1f6b528552cf45d5c9494e4826f3
parent6c560288a6329305ae3327a589e072e56bc9970d
hugolib: Speed up GetPage

When we know to look into the index pages collection, do that:

```
benchmark              old ns/op     new ns/op     delta
BenchmarkGetPage-4     51483         7072          -86.26%

benchmark              old allocs     new allocs     delta
BenchmarkGetPage-4     71             71             +0.00%

benchmark              old bytes     new bytes     delta
BenchmarkGetPage-4     2648          2648          +0.00%
```

This commit also returns an error if .Site.GetPage is called with the regular Page Kind, as that is currently not supported.

Fixes #3503
hugolib/page_collections.go
hugolib/site.go