diff options
Diffstat (limited to 'internal/readings/readings.go')
| -rw-r--r-- | internal/readings/readings.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/internal/readings/readings.go b/internal/readings/readings.go index d0d7bf9..29eff5a 100644 --- a/internal/readings/readings.go +++ b/internal/readings/readings.go @@ -25,8 +25,22 @@ type Options struct { // liturgical colour -- see liturgy.DayInfo) for the configured form // (cfg.Lectionary: "traditional" or "new") and applies part filtering. Every // reading is resolved offline from the embedded calendar and lectionary data. +// +// Load is LoadWith(Prepare(cfg), cfg, opts) -- a single call's worth of +// convenience. A caller resolving several dates against the same cfg (a +// week/month view) should call Prepare once and use LoadWith directly instead +// of paying Prepare's cost on every date; see Prepared's doc comment +// (internal/readings/offline.go). func Load(cfg config.Config, opts Options) ([]liturgy.Section, liturgy.DayInfo, error) { - secs, info, err := offlineLoad(cfg, opts.Date) + return LoadWith(Prepare(cfg), cfg, opts) +} + +// LoadWith is Load, given an already-built Prepared (see Prepare) instead of +// building its own. Reuse one Prepared across every date resolved against the +// same cfg to skip re-stacking the calendar layers and re-parsing the book +// table per date -- the fast path mobile.Days's multi-day loop uses. +func LoadWith(p Prepared, cfg config.Config, opts Options) ([]liturgy.Section, liturgy.DayInfo, error) { + secs, info, err := offlineLoadWith(p, cfg, opts.Date) if err != nil { return nil, liturgy.DayInfo{}, err } |
