Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/jruby-9.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Sep 4, 2023
2 parents b8b1a42 + 8ccff43 commit 656f9d6
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
Expand Up @@ -3077,12 +3077,12 @@ public void loadExtension(String extName, BasicLibraryService extension, boolean
}

public void addBoundMethod(String className, String methodName, String rubyName) {
Map<String, String> javaToRuby = boundMethods.computeIfAbsent(className, s -> new HashMap<>());
Map<String, String> javaToRuby = boundMethods.computeIfAbsent(className, s -> new ConcurrentHashMap<>(2, 0.9f, 2));
javaToRuby.putIfAbsent(methodName, rubyName);
}

public void addBoundMethods(String className, String... tuples) {
Map<String, String> javaToRuby = boundMethods.computeIfAbsent(className, s -> new HashMap<>());
Map<String, String> javaToRuby = boundMethods.computeIfAbsent(className, s -> new ConcurrentHashMap<>(2, 0.9f, 2));
for (int i = 0; i < tuples.length; i += 2) {
javaToRuby.putIfAbsent(tuples[i], tuples[i+1]);
}
Expand All @@ -3097,10 +3097,9 @@ public void addBoundMethods(int tuplesIndex, String... classNamesAndTuples) {

for (int i = 0; i < tuplesIndex; i++) {
String className = classNamesAndTuples[i];
if (boundMethods.containsKey(className)) {
boundMethods.get(className).putAll(javaToRuby);
} else {
boundMethods.put(className, new HashMap<>(javaToRuby));
Map<String, String> javaToRubyForClass = boundMethods.computeIfAbsent(className, s -> new ConcurrentHashMap<>((int)(javaToRuby.size() / 0.9f) + 1, 0.9f, 2));
for (Map.Entry<String, String> entry : javaToRuby.entrySet()) {
javaToRubyForClass.putIfAbsent(entry.getKey(), entry.getValue());
}
}
}
Expand Down Expand Up @@ -5578,7 +5577,7 @@ public void warn(String message) {
private final AtomicInteger moduleGeneration = new AtomicInteger(1);

// A list of Java class+method names to include in backtraces
private final Map<String, Map<String, String>> boundMethods = new HashMap();
private final Map<String, Map<String, String>> boundMethods = new ConcurrentHashMap<>();

// A soft pool of selectors for blocking IO operations
private final SelectorPool selectorPool = new SelectorPool();
Expand Down

0 comments on commit 656f9d6

Please sign in to comment.