Skip to content

Commit 1248d78

Browse files
Minor agenda view optimization.
1 parent a7ba7ef commit 1248d78

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

lua/orgmode/agenda/init.lua

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -438,17 +438,25 @@ function Agenda:agenda()
438438
local dates = self.from:get_range_until(self.to)
439439
local agenda_days = {}
440440

441+
local headline_dates = {}
442+
for _, orgfile in ipairs(Files.all()) do
443+
for _, headline in ipairs(orgfile:get_opened_headlines()) do
444+
for _, headline_date in ipairs(headline:get_valid_dates_for_agenda()) do
445+
table.insert(headline_dates, {
446+
headline_date = headline_date,
447+
headline = headline,
448+
})
449+
end
450+
end
451+
end
452+
441453
for _, day in ipairs(dates) do
442454
local date = { day = day, agenda_items = {} }
443455

444-
for _, orgfile in ipairs(Files.all()) do
445-
for _, headline in ipairs(orgfile:get_opened_headlines()) do
446-
for _, headline_date in ipairs(headline:get_valid_dates_for_agenda()) do
447-
local item = AgendaItem:new(headline_date, headline, day)
448-
if item.is_valid then
449-
table.insert(date.agenda_items, item)
450-
end
451-
end
456+
for _, item in ipairs(headline_dates) do
457+
local item = AgendaItem:new(item.headline_date, item.headline, day)
458+
if item.is_valid then
459+
table.insert(date.agenda_items, item)
452460
end
453461
end
454462

0 commit comments

Comments
 (0)