summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/strc-doc.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-06-22 16:42:14 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2018-06-22 16:42:14 +0200
commitda8162d4e816cf49d9790a1c81556b499f442bed (patch)
tree5c631b1fb8282670a6cea1087afa766a8b94db43 /tex/context/base/mkiv/strc-doc.lua
parent204057fdc5023b5f4ff55a69bc6593388ea427e7 (diff)
downloadcontext-da8162d4e816cf49d9790a1c81556b499f442bed.tar.gz
2018-06-22 16:02:00
Diffstat (limited to 'tex/context/base/mkiv/strc-doc.lua')
-rw-r--r--tex/context/base/mkiv/strc-doc.lua60
1 files changed, 32 insertions, 28 deletions
diff --git a/tex/context/base/mkiv/strc-doc.lua b/tex/context/base/mkiv/strc-doc.lua
index 80e41451e..f2674ea5a 100644
--- a/tex/context/base/mkiv/strc-doc.lua
+++ b/tex/context/base/mkiv/strc-doc.lua
@@ -124,12 +124,16 @@ local tobesaved = allocate()
sections.collected = collected
sections.tobesaved = tobesaved
--- local function initializer()
--- collected = sections.collected
--- tobesaved = sections.tobesaved
--- end
---
--- job.register('structures.sections.collected', tobesaved, initializer)
+-- We have to save this mostly redundant list because we can have (rare)
+-- cases with own numbers that don't end up in the list so we get out of
+-- sync when we use (*).
+
+local function initializer()
+ collected = sections.collected
+ tobesaved = sections.tobesaved
+end
+
+job.register('structures.sections.collected', tobesaved, initializer)
local registered = sections.registered or allocate()
sections.registered = registered
@@ -160,7 +164,7 @@ end
local lastsaved = 0
function sections.save(sectiondata)
--- local sectionnumber = helpers.simplify(section.sectiondata) -- maybe done earlier
+local sectiondata = helpers.simplify(sectiondata) -- maybe done earlier
local numberdata = sectiondata.numberdata
local ntobesaved = #tobesaved
if not numberdata or sectiondata.metadata.nolist then
@@ -180,28 +184,28 @@ function sections.currentsectionindex()
return lastsaved -- only for special controlled situations
end
-function sections.load()
- setmetatableindex(collected,nil)
- local lists = lists.collected
- for i=1,#lists do
- local list = lists[i]
- local metadata = list.metadata
- if metadata and metadata.kind == "section" and not metadata.nolist then
- local numberdata = list.numberdata
- if numberdata then
- collected[#collected+1] = numberdata
- end
- end
- end
- sections.load = functions.dummy
-end
-
-table.setmetatableindex(collected, function(t,i)
- sections.load()
- return collected[i] or { }
-end)
-
+-- See comment above (*). We cannot use the following space optimization:
+--
+-- function sections.load()
+-- setmetatableindex(collected,nil)
+-- local lists = lists.collected
+-- for i=1,#lists do
+-- local list = lists[i]
+-- local metadata = list.metadata
+-- if metadata and metadata.kind == "section" and not metadata.nolist then
+-- local numberdata = list.numberdata
+-- if numberdata then
+-- collected[#collected+1] = numberdata
+-- end
+-- end
+-- end
+-- sections.load = functions.dummy
+-- end
--
+-- table.setmetatableindex(collected, function(t,i)
+-- sections.load()
+-- return collected[i] or { }
+-- end)
sections.verbose = true