perf(sync): share the bounded converter cache for section percentages

Per-annotation percentage derivation (deriveAnnotationPercentage) built a
fresh CFIConverter for every highlight/note/bookmark, re-reading and
re-parsing the whole EPUB each time. Export SectionPercentageCached so
handlers reach the same bounded cache ConvertToCanonical already uses
(8 books, insertion-order eviction): one parse per book per push instead
of one per annotation.
This commit is contained in:
2026-09-09 09:04:10 -04:00
parent 7b1c809ae3
commit 5a6c361c11
+7
View File
@@ -58,6 +58,13 @@ func cachedConverter(epubPath string) *CFIConverter {
return c
}
// SectionPercentageCached resolves the spine-section percentage of a CRE
// xpointer through the shared bounded converter cache, so per-annotation
// lookups parse the EPUB once per book instead of once per annotation.
func SectionPercentageCached(epubPath, xpointer string) float64 {
return cachedConverter(epubPath).SectionPercentage(xpointer)
}
func ConvertToCanonical(
source LocatorSource,
devicePos string,