Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
Expand Up @@ -1256,14 +1256,16 @@ protected void mutateChilledString() {
*/
public static class FString extends RubyString {
private IRubyObject converted;
private final long hash;
private final int hash;
private final RubyFixnum fixHash;

protected FString(Ruby runtime, ByteList value, int cr) {
super(runtime, runtime.getString(), value, cr, false);

this.shareLevel = SHARE_LEVEL_BYTELIST;
this.setFrozen(true);
this.hash = strHashCode(runtime);
this.fixHash = runtime.newFixnum(hash);
}

protected FString(Ruby runtime, String string) {
Expand All @@ -1272,6 +1274,7 @@ protected FString(Ruby runtime, String string) {
this.shareLevel = SHARE_LEVEL_BYTELIST;
this.setFrozen(true);
this.hash = strHashCode(runtime);
this.fixHash = runtime.newFixnum(hash);
}

@Override
Expand Down Expand Up @@ -1319,6 +1322,15 @@ public FString dupAsFString(Ruby runtime) {
return this;
}

public RubyFixnum hash(ThreadContext context) {
return fixHash;
}

@Override
public int hashCode() {
return hash;
}

@Override
public long longHashCode() {
return hash;
Expand Down