MCPcopy Create free account
hub / github.com/FastLED/FastLED / insert

Method insert

src/fl/stl/unordered_map_lru.h:62–83  ·  view source on GitHub ↗

Insert or update a key-value pair

Source from the content-addressed store, hash-verified

60
61 // Insert or update a key-value pair
62 void insert(const Key &key, const T &value) {
63 // Only evict if we're at capacity AND this is a new key
64 const ValueWithTimestamp *existing = mMap.find_value(key);
65
66 auto curr = mCurrentTime++;
67
68 if (existing) {
69 // Update the value and access time
70 ValueWithTimestamp &vwt =
71 const_cast<ValueWithTimestamp &>(*existing);
72 vwt.value = value;
73 vwt.last_access_time = curr;
74 return;
75 }
76 if (mMap.size() >= mMaxSize) {
77 evictOldest();
78 }
79
80 // Insert or update the value with current timestamp
81 ValueWithTimestamp vwt(value, mCurrentTime);
82 mMap.insert(key, vwt);
83 }
84
85 // Get value for key, returns nullptr if not found
86 T *find_value(const Key &key) {

Callers

nothing calls this directly

Calls 2

find_valueMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected