Skip to content

Commit 7b881c7

Browse files
committed
Avoid syncrhonization if the RbEncoding is already native
1 parent 9c7d15d commit 7b881c7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/truffle/truffle/cext_structs.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,12 @@ def polyglot_pointer?
497497
end
498498

499499
def polyglot_to_native
500-
ENCODING_CACHE_MUTEX.synchronize do
501-
unless @pointer
502-
@pointer = Truffle::CExt::LIBTRUFFLERUBY.rb_encoding_to_native(@name)
503-
NATIVE_CACHE[Truffle::Interop.as_pointer(@pointer)] = self
500+
unless @pointer
501+
ENCODING_CACHE_MUTEX.synchronize do
502+
unless @pointer
503+
@pointer = Truffle::CExt::LIBTRUFFLERUBY.rb_encoding_to_native(@name)
504+
NATIVE_CACHE[Truffle::Interop.as_pointer(@pointer)] = self
505+
end
504506
end
505507
end
506508
end

0 commit comments

Comments
 (0)