odilia-app/odilia

Cache Should Modify in-place

Closed this issue · 1 comments

TTWNO commented

See title, use .get_mut()

Especially useful for text-changed events, if we decide to store the text of the element.

Personally, I think the memory usage far out-weighs the speed it takes to query an accessible for its text. Plus, this would allow Odilia to search the tree for something in particular, even if it's not in an application which supports it—sounds cool, but obviously those CacheItem elements could get pretty big. If we assume the size of your average sentence is somewhere around 200 characters, and we have maybe 4 sentences in an item, we could see larger CacheItems with sizes above 1KB. But, I think this would be the exception and not the rule: even 10,000 items containing paragraphs of that size would be in the realm of 10MB of RAM.

Anyway, not really the point of this bug, but it is something we will probably support in the future.

EDIT: Currently the cache must copy the entire CacheItem struct, modify it, then set it again.

TTWNO commented

Done on local. I'll push doon!