Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 55d74cb0b60c
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8842dec1470a
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Sep 26, 2016

  1. Copy the full SHA
    4df9567 View commit details
  2. 2
    Copy the full SHA
    8842dec View commit details
Showing with 2 additions and 11 deletions.
  1. +2 −11 truffle/src/main/java/org/jruby/truffle/language/globals/GlobalVariables.java
Original file line number Diff line number Diff line change
@@ -21,12 +21,10 @@
public class GlobalVariables {

private final DynamicObject defaultValue;

ConcurrentMap<String, GlobalVariableStorage> variables;
private final ConcurrentMap<String, GlobalVariableStorage> variables = new ConcurrentHashMap<>();

public GlobalVariables(DynamicObject defaultValue) {
this.defaultValue = defaultValue;
this.variables = new ConcurrentHashMap<>();
}

public Object getOrDefault(String key, Object defaultValue) {
@@ -40,14 +38,7 @@ public Object get(String key) {

@TruffleBoundary
public GlobalVariableStorage getStorage(String key) {
final GlobalVariableStorage currentStorage = variables.get(key);
if (currentStorage == null) {
final GlobalVariableStorage newStorage = new GlobalVariableStorage(defaultValue);
final GlobalVariableStorage prevStorage = variables.putIfAbsent(key, newStorage);
return (prevStorage == null) ? newStorage : prevStorage;
} else {
return currentStorage;
}
return variables.computeIfAbsent(key, k -> new GlobalVariableStorage(defaultValue));
}

public GlobalVariableStorage put(String key, Object value) {