Skip to content

Commit 9bd16bb

Browse files
committed
Conc::Map - MRI backend can't use native Hash#value?
Hash#value? bumps internal hash iteration level and under certain circumstances might yield GVL. This in turn exposes users to potential "modification during iteration" errors.
1 parent 8b12b1e commit 9bd16bb

File tree

3 files changed

+1
-9
lines changed

3 files changed

+1
-9
lines changed

lib/concurrent/collection/map/non_concurrent_map_backend.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ def key?(key)
7676
@backend.key?(key)
7777
end
7878

79-
def value?(value)
80-
@backend.value?(value)
81-
end
82-
8379
def delete(key)
8480
@backend.delete(key)
8581
end

lib/concurrent/collection/map/synchronized_map_backend.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ def key?(key)
5353
synchronize { super }
5454
end
5555

56-
def value?(value)
57-
synchronize { super }
58-
end
59-
6056
def delete(key)
6157
synchronize { super }
6258
end

lib/concurrent/map.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def value?(value)
149149
return true if value.equal?(v)
150150
end
151151
false
152-
end unless method_defined?(:value?)
152+
end
153153

154154
def keys
155155
arr = []

0 commit comments

Comments
 (0)