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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user