Skip to content

Commit

Permalink
Showing 5 changed files with 11 additions and 112 deletions.
Original file line number Diff line number Diff line change
@@ -220,7 +220,7 @@ public Object isCompatibleSymbolRegexp(DynamicObject first, DynamicObject second
@TruffleBoundary
@Specialization(guards = {"isRubyString(first)", "isRubySymbol(second)"})
public Object isCompatibleStringSymbol(DynamicObject first, DynamicObject second) {
final Encoding compatibleEncoding = org.jruby.RubyEncoding.areCompatible(StringOperations.getCodeRangeableReadOnly(first), SymbolNodes.getCodeRangeable(second));
final Encoding compatibleEncoding = compatibleEncodingForRopes(StringOperations.rope(first), Layouts.SYMBOL.getRope(second));

if (compatibleEncoding != null) {
return getEncoding(compatibleEncoding);
@@ -232,7 +232,7 @@ public Object isCompatibleStringSymbol(DynamicObject first, DynamicObject second
@TruffleBoundary
@Specialization(guards = {"isRubySymbol(first)", "isRubySymbol(second)"})
public Object isCompatibleSymbolSymbol(DynamicObject first, DynamicObject second) {
final Encoding compatibleEncoding = org.jruby.RubyEncoding.areCompatible(SymbolNodes.getCodeRangeable(first), SymbolNodes.getCodeRangeable(second));
final Encoding compatibleEncoding = compatibleEncodingForRopes(Layouts.SYMBOL.getRope(first), Layouts.SYMBOL.getRope(second));

if (compatibleEncoding != null) {
return getEncoding(compatibleEncoding);
@@ -263,6 +263,13 @@ public static Encoding compatibleEncodingForStrings(DynamicObject first, Dynamic
final Rope firstRope = StringOperations.rope(first);
final Rope secondRope = StringOperations.rope(second);

return compatibleEncodingForRopes(firstRope, secondRope);
}

@TruffleBoundary
public static Encoding compatibleEncodingForRopes(Rope firstRope, Rope secondRope) {
// Taken from org.jruby.RubyEncoding#areCompatible.

final Encoding firstEncoding = firstRope.getEncoding();
final Encoding secondEncoding = secondRope.getEncoding();

This file was deleted.

Original file line number Diff line number Diff line change
@@ -24,8 +24,7 @@ DynamicObjectFactory createSymbolShape(DynamicObject logicalClass,
DynamicObject createSymbol(DynamicObjectFactory factory,
String string,
Rope rope,
int hashCode,
@Nullable SymbolCodeRangeableWrapper codeRangeableWrapper);
int hashCode);

boolean isSymbol(Object object);
boolean isSymbol(DynamicObject object);
@@ -36,7 +35,4 @@ DynamicObject createSymbol(DynamicObjectFactory factory,

int getHashCode(DynamicObject object);

SymbolCodeRangeableWrapper getCodeRangeableWrapper(DynamicObject object);
void setCodeRangeableWrapper(DynamicObject object, SymbolCodeRangeableWrapper value);

}
Original file line number Diff line number Diff line change
@@ -43,20 +43,6 @@
@CoreClass(name = "Symbol")
public abstract class SymbolNodes {

public static SymbolCodeRangeableWrapper getCodeRangeable(DynamicObject symbol) {
SymbolCodeRangeableWrapper wrapper = Layouts.SYMBOL.getCodeRangeableWrapper(symbol);

if (wrapper != null) {
return wrapper;
}

wrapper = new SymbolCodeRangeableWrapper(symbol);

Layouts.SYMBOL.setCodeRangeableWrapper(symbol, wrapper);

return wrapper;
}

@CoreMethod(names = "all_symbols", onSingleton = true)
public abstract static class AllSymbolsNode extends CoreMethodArrayArgumentsNode {

Original file line number Diff line number Diff line change
@@ -123,8 +123,7 @@ public DynamicObject getSymbol(Rope rope) {
Layouts.CLASS.getInstanceFactory(symbolClass),
string,
flattenedRope,
string.hashCode(),
null);
string.hashCode());

symbolsTable.put(flattenedRope, new WeakReference<>(newSymbol));
return newSymbol;

0 comments on commit 2403597

Please sign in to comment.