Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
proximity
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mathis "what could possibly go wrong" Randl
proximity
Commits
9524c4cb
Commit
9524c4cb
authored
3 weeks ago
by
Mathis "what could possibly go wrong" Randl
Browse files
Options
Downloads
Patches
Plain Diff
with pre-allocated capacity
parent
a0ecb060
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/caching/bounded/fifo/fifo_cache.rs
+1
-1
1 addition, 1 deletion
core/src/caching/bounded/fifo/fifo_cache.rs
core/src/caching/bounded/lru/lru_cache.rs
+2
-2
2 additions, 2 deletions
core/src/caching/bounded/lru/lru_cache.rs
with
3 additions
and
3 deletions
core/src/caching/bounded/fifo/fifo_cache.rs
+
1
−
1
View file @
9524c4cb
...
...
@@ -44,7 +44,7 @@ impl<K, V> FifoCache<K, V> {
assert!
(
tolerance
>
0.0
);
Self
{
max_capacity
,
items
:
VecDeque
::
new
(
),
items
:
VecDeque
::
with_capacity
(
max_capacity
),
tolerance
,
}
}
...
...
This diff is collapsed.
Click to expand it.
core/src/caching/bounded/lru/lru_cache.rs
+
2
−
2
View file @
9524c4cb
...
...
@@ -72,7 +72,7 @@ where
}
fn
insert
(
&
mut
self
,
key
:
K
,
value
:
V
)
{
if
self
.len
()
=
=
self
.max_capacity
{
if
self
.len
()
>
=
self
.max_capacity
{
if
let
Some
(
tail
)
=
self
.list
.remove_tail
()
{
self
.map
.remove
(
&
tail
.borrow
()
.key
);
}
...
...
@@ -93,7 +93,7 @@ impl<K, V> LRUCache<K, V> {
assert!
(
tolerance
>
0.0
);
Self
{
max_capacity
,
map
:
HashMap
::
new
(
),
map
:
HashMap
::
with_capacity
(
max_capacity
),
list
:
DoublyLinkedList
::
new
(),
tolerance
,
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment