Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few frozen string and symbol optimizations #8177

Merged
merged 7 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions core/src/main/java/org/jruby/ObjectFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ public interface ObjectFlags {
int NIL_F = registry.newFlag(RubyBasicObject.class);
int FROZEN_F = registry.newFlag(RubyBasicObject.class);

// Deprecated and unused but don't move due to checks elsewhere for the following flags
@Deprecated
int TAINTED_F = registry.newFlag(RubyBasicObject.class);

int CACHEPROXY_F = registry.newFlag(RubyModule.class);
int NEEDSIMPL_F = registry.newFlag(RubyModule.class);
int REFINED_MODULE_F = registry.newFlag(RubyModule.class);
Expand All @@ -26,6 +22,7 @@ public interface ObjectFlags {

int CR_7BIT_F = registry.newFlag(RubyString.class);
int CR_VALID_F = registry.newFlag(RubyString.class);
int FSTRING = registry.newFlag(RubyString.class);

int MATCH_BUSY = registry.newFlag(RubyMatchData.class);

Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
Expand Up @@ -4874,6 +4874,7 @@ public RubyString freezeAndDedupString(RubyString string) {

// Never use incoming value as key
deduped = string.strDup(this);
deduped.setFlag(ObjectFlags.FSTRING, true);
deduped.setFrozen(true);

final WeakReference<RubyString> weakref = new WeakReference<>(deduped);
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/util/StringSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public final class StringSupport {
public static final int CR_UNKNOWN = 0;

// We hardcode these so they can be used in a switch below. The assert verifies they match FlagRegistry's value.
public static final int CR_7BIT = 16;
public static final int CR_VALID = 32;
public static final int CR_7BIT = 8;
headius marked this conversation as resolved.
Show resolved Hide resolved
public static final int CR_VALID = 16;
static {
assert CR_7BIT == CR_7BIT_F : "CR_7BIT = " + CR_7BIT + " but should be " + CR_7BIT_F;
assert CR_VALID == CR_VALID_F : "CR_VALID = " + CR_VALID + " but should be " + CR_VALID_F;
Expand Down