aboutsummaryrefslogtreecommitdiff
path: root/mobile/mobile.go
diff options
context:
space:
mode:
Diffstat (limited to 'mobile/mobile.go')
-rw-r--r--mobile/mobile.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/mobile/mobile.go b/mobile/mobile.go
index 7e4c109..bc380d2 100644
--- a/mobile/mobile.go
+++ b/mobile/mobile.go
@@ -78,7 +78,12 @@ func Day(date, form, version, lang string) string {
// Day identity (name/season/colour) in the interface language.
cfgID := config.Config{UILanguage: lang, Lectionary: lect, All: true}
- if _, info, err := readings.Load(cfgID, readings.Options{Date: date, All: true}); err == nil {
+ // cfgID and cfgR below differ only in UILanguage/ReadingVersion, never in
+ // Lectionary or Use -- the two inputs Prepare's cost depends on -- so one
+ // Prepare (keyed off cfgID; either config would do) serves both Load
+ // calls. See readings.Prepared's doc comment.
+ p := readings.Prepare(cfgID)
+ if _, info, err := readings.LoadWith(p, cfgID, readings.Options{Date: date, All: true}); err == nil {
out.Name = info.Name
out.Season = info.Season
out.Colour = info.Colour
@@ -92,7 +97,7 @@ func Day(date, form, version, lang string) string {
// language localizes the structural labels (Heading) and citation dialect;
// the corpus (version) alone decides the scripture text.
cfgR := config.Config{UILanguage: lang, Lectionary: lect, ReadingVersion: version, All: true}
- secs, _, err := readings.Load(cfgR, readings.Options{Date: date, All: true})
+ secs, _, err := readings.LoadWith(p, cfgR, readings.Options{Date: date, All: true})
if err != nil {
if out.Error == "" {
out.Error = err.Error()
@@ -166,12 +171,17 @@ func Days(start string, count int, form, lang string) string {
lect := lectByForm(form)
ui := i18n.Get(lang)
cfg := config.Config{UILanguage: lang, Lectionary: lect, All: true}
+ // cfg is identical for every date in the loop below, so the layer stack
+ // and book table it implies are too -- Prepare once here rather than
+ // letting each readings.Load call re-stack/re-parse them. See
+ // readings.Prepared's doc comment.
+ p := readings.Prepare(cfg)
out := make([]daySummary, 0, count)
for i := 0; i < count; i++ {
date := d.AddDate(0, 0, i).Format("2006-01-02")
row := daySummary{Date: date, Parts: []summaryPart{}}
- secs, info, err := readings.Load(cfg, readings.Options{Date: date, All: true})
+ secs, info, err := readings.LoadWith(p, cfg, readings.Options{Date: date, All: true})
if err != nil {
row.Error = err.Error()
} else {