Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions core/src/main/java/org/jruby/RubyHash.java
Original file line number Diff line number Diff line change
Expand Up @@ -1259,12 +1259,12 @@ public void setRuby2KeywordHash(boolean value) {
getDelegate().setRuby2KeywordHash(value);
}

protected void set(int flag, boolean set) {
getDelegate().set(flag, set);
protected void setHashFlag(int flag, boolean set) {
getDelegate().setHashFlag(flag, set);
}

protected boolean get(int flag) {
return getDelegate().get(flag);
protected boolean hasHashFlag(int flag) {
return getDelegate().hasHashFlag(flag);
}

// Still used by jruby-openssl
Expand Down
42 changes: 21 additions & 21 deletions core/src/main/java/org/jruby/RubyHashLinkedBuckets.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ public static RubyHashLinkedBuckets newLBHash(Ruby runtime, IRubyObject defaultV
return new RubyHashLinkedBuckets(runtime, defaultValue, buckets);
}

protected void set(int flag, boolean set) {
protected void setHashFlag(int flag, boolean set) {
if (set) {
hashFlags |= flag;
} else {
hashFlags &= ~flag;
}
}

protected boolean get(int flag) {
protected boolean hasHashFlag(int flag) {
return (hashFlags & flag) != 0;
}

Expand Down Expand Up @@ -576,7 +576,7 @@ public IRubyObject initialize(ThreadContext context, final Block block) {

if (block.isGiven()) {
ifNone = context.runtime.newProc(Block.Type.PROC, block);
set(PROCDEFAULT_HASH, true);
setHashFlag(PROCDEFAULT_HASH, true);
} else {
ifNone = UNDEF;
}
Expand All @@ -595,7 +595,7 @@ public IRubyObject initialize(ThreadContext context, IRubyObject _default, final

if (block.isGiven()) {
ifNone = context.runtime.newProc(Block.Type.PROC, block);
set(PROCDEFAULT_HASH, true);
setHashFlag(PROCDEFAULT_HASH, true);
} else {
ifNone = UNDEF;
}
Expand Down Expand Up @@ -628,15 +628,15 @@ public IRubyObject initialize(ThreadContext context, IRubyObject _default, IRuby

@JRubyMethod(name = "default")
public IRubyObject default_value_get(ThreadContext context) {
if (get(PROCDEFAULT_HASH)) {
if (hasHashFlag(PROCDEFAULT_HASH)) {
return context.nil;
}
return ifNone == UNDEF ? context.nil : ifNone;
}

@JRubyMethod(name = "default")
public IRubyObject default_value_get(ThreadContext context, IRubyObject arg) {
if (get(PROCDEFAULT_HASH)) {
if (hasHashFlag(PROCDEFAULT_HASH)) {
return sites(context).call.call(context, ifNone, ifNone, this, arg);
}
return ifNone == UNDEF ? context.nil : ifNone;
Expand All @@ -650,7 +650,7 @@ public IRubyObject default_value_set(ThreadContext context, final IRubyObject de
modify();

ifNone = defaultValue;
set(PROCDEFAULT_HASH, false);
setHashFlag(PROCDEFAULT_HASH, false);

return ifNone;
}
Expand All @@ -660,7 +660,7 @@ public IRubyObject default_value_set(ThreadContext context, final IRubyObject de
*/
@JRubyMethod
public IRubyObject default_proc(ThreadContext context) {
return get(PROCDEFAULT_HASH) ? ifNone : context.nil;
return hasHashFlag(PROCDEFAULT_HASH) ? ifNone : context.nil;
}

/** default_proc_arity_check
Expand All @@ -684,7 +684,7 @@ public IRubyObject set_default_proc(ThreadContext context, IRubyObject proc) {

if (proc.isNil()) {
ifNone = proc;
set(PROCDEFAULT_HASH, false);
setHashFlag(PROCDEFAULT_HASH, false);
return proc;
}

Expand All @@ -694,7 +694,7 @@ public IRubyObject set_default_proc(ThreadContext context, IRubyObject proc) {
proc = b;
checkDefaultProcArity(context, ((RubyProc) proc).getBlock());
ifNone = proc;
set(PROCDEFAULT_HASH, true);
setHashFlag(PROCDEFAULT_HASH, true);
return proc;
}

Expand Down Expand Up @@ -1971,10 +1971,10 @@ public RubyHash replace(final ThreadContext context, IRubyObject other) {

ifNone = otherHash.getIfNone();

if (otherHash.get(PROCDEFAULT_HASH)) {
set(PROCDEFAULT_HASH, true);
if (otherHash.hasHashFlag(PROCDEFAULT_HASH)) {
setHashFlag(PROCDEFAULT_HASH, true);
} else {
set(PROCDEFAULT_HASH, false);
setHashFlag(PROCDEFAULT_HASH, false);
}

return this;
Expand Down Expand Up @@ -2207,10 +2207,10 @@ public RubyHashLinkedBuckets dupFast(final ThreadContext context) {

dup.ifNone = this.ifNone;

if (this.get(PROCDEFAULT_HASH)) {
dup.set(PROCDEFAULT_HASH, true);
if (this.hasHashFlag(PROCDEFAULT_HASH)) {
dup.setHashFlag(PROCDEFAULT_HASH, true);
} else {
dup.set(PROCDEFAULT_HASH, false);
dup.setHashFlag(PROCDEFAULT_HASH, false);
}

return dup;
Expand All @@ -2222,7 +2222,7 @@ public RubyHashLinkedBuckets withRuby2Keywords(boolean ruby2Keywords) {
}

public boolean hasDefaultProc() {
return get(PROCDEFAULT_HASH);
return hasHashFlag(PROCDEFAULT_HASH);
}

public IRubyObject getIfNone(){
Expand Down Expand Up @@ -2434,7 +2434,7 @@ private final RaiseException concurrentModification() {
* @return true if this object is compared by identity, false otherwise
*/
public boolean isComparedByIdentity() {
return get(COMPARE_BY_IDENTITY);
return hasHashFlag(COMPARE_BY_IDENTITY);
}

/**
Expand All @@ -2443,15 +2443,15 @@ public boolean isComparedByIdentity() {
* @param comparedByIdentity should this object be compared by identity?
*/
public void setComparedByIdentity(boolean comparedByIdentity) {
set(COMPARE_BY_IDENTITY, comparedByIdentity);
setHashFlag(COMPARE_BY_IDENTITY, comparedByIdentity);
}

public boolean isRuby2KeywordHash() {
return get(RUBY2_KEYWORD);
return hasHashFlag(RUBY2_KEYWORD);
}

public void setRuby2KeywordHash(boolean value) {
set(RUBY2_KEYWORD, value);
setHashFlag(RUBY2_KEYWORD, value);
}

private class BaseSet extends AbstractSet {
Expand Down
Loading