Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,12 @@ private static void Add(Key key, Regex regex)
}
}

// Remove the key found to have the smallest access stamp.
// Remove the key found to have the smallest access stamp. List ordering isn't important, so rather than
// just removing the element at minListIndex, which would result in an O(N) shift down, we copy the last
Comment thread
stephentoub marked this conversation as resolved.
// element to minListIndex, and then remove the last. (If minListIndex is the last, this is a no-op.)
s_cacheDictionary.TryRemove(s_cacheList[minListIndex].Key, out _);
s_cacheList.RemoveAt(minListIndex);
s_cacheList[minListIndex] = s_cacheList[^1];
s_cacheList.RemoveAt(s_cacheList.Count - 1);
}

// Finally add the regex.
Expand Down