MCPcopy Create free account
hub / github.com/Luce-Org/lucebox-hub / confirm_inline_snap

Method confirm_inline_snap

server/src/server/prefix_cache.cpp:295–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293 return;
294 }
295 disabled_ = false;
296 std::fprintf(stderr, "[pc] enabled: cap=%d family=%s\n", cap_, markers_.family.c_str());
297}
298
299// ── LRU helpers ─────────────────────────────────────────────────────────
300
301int PrefixCache::find_entry(const PrefixHash & h) const {
302 for (int i = 0; i < (int)entries_.size(); i++) {
303 if (entries_[i].hash == h) return i;
304 }
305 return -1;
306}
307
308void PrefixCache::move_to_end(int idx) {
309 if (idx < 0 || idx >= (int)entries_.size()) return;
310 auto e = std::move(entries_[idx]);
311 entries_.erase(entries_.begin() + idx);
312 entries_.push_back(std::move(e));
313}
314
315int PrefixCache::find_full_entry(const PrefixHash & h) const {
316 for (int i = 0; i < (int)full_entries_.size(); i++) {
317 if (full_entries_[i].hash == h) return i;
318 }
319 return -1;
320}
321
322void PrefixCache::move_full_to_end(int idx) {
323 if (idx < 0 || idx >= (int)full_entries_.size()) return;
324 auto e = std::move(full_entries_[idx]);
325 full_entries_.erase(full_entries_.begin() + idx);
326 full_entries_.push_back(std::move(e));
327}
328
329// ── Inline prefix cache ─────────────────────────────────────────────────
330
331std::pair<int, int> PrefixCache::lookup(const std::vector<int32_t> & prompt_ids) {
332 if (disabled_) return {-1, 0};
333

Callers 1

worker_loopMethod · 0.80

Calls 3

hash_prefixFunction · 0.85
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected