#pragma once // Spec: SPEC.md UX-MD-01. Small LRU of parsed documents keyed by text hash; views are rebuilt every frame. #include #include #include #include #include "ui/MarkdownParser.hpp" namespace dp::ui { class MarkdownCache { public: static MarkdownCache& instance(); // UI thread. Parses on a miss. The hash selects the entry, the full text confirms it. std::shared_ptr get(const std::string& markdown); std::size_t size() const { return entries_.size(); } std::uint64_t parses() const { return parses_; } void clear() { entries_.clear(); } private: struct Entry { std::uint64_t hash; std::string text; std::shared_ptr doc; }; std::list entries_; // front = most recent std::uint64_t parses_ = 0; }; } // namespace dp::ui