Permalink
Browse files

fix up calls to invalidateConstantCache() in RubyModule

  • Loading branch information...
1 parent d3d3329 commit 51551463515b8fa5fd7a530187dc54b192892aa9 @charliesome committed Jun 11, 2013
Showing with 24 additions and 21 deletions.
  1. +24 −21 src/org/jruby/RubyModule.java
@@ -986,9 +986,8 @@ private CacheEntry cacheHit(String name) {
private void invalidateConstantCacheForModuleInclusion(RubyModule module)
{
for (RubyModule mod : gatherModules(module)) {
- if (!mod.getConstantMap().isEmpty()) {
- invalidateConstantCache();
- break;
+ for (String key : mod.getConstantMap().keySet()) {
+ invalidateConstantCache(key);
}
}
}
@@ -1144,8 +1143,8 @@ protected void invalidateCacheDescendantsInner() {
methodInvalidator.invalidate();
}
- protected void invalidateConstantCache() {
- getRuntime().getConstantInvalidator().invalidate();
+ protected void invalidateConstantCache(String constantName) {
+ getRuntime().getConstantInvalidator(constantName).invalidate();
}
/**
@@ -2619,7 +2618,7 @@ public IRubyObject remove_const(ThreadContext context, IRubyObject rubyName) {
String name = validateConstant(rubyName.asJavaString());
IRubyObject value;
if ((value = deleteConstant(name)) != null) {
- invalidateConstantCache();
+ invalidateConstantCache(name);
if (value != UNDEF) {
return value;
}
@@ -2731,34 +2730,38 @@ public RubyArray constantsCommon19(ThreadContext context, boolean replaceModule,
}
@JRubyMethod(compat = RUBY1_9)
- public IRubyObject private_constant(ThreadContext context, IRubyObject name) {
- setConstantVisibility(context, validateConstant(name.asJavaString()), true);
- invalidateConstantCache();
+ public IRubyObject private_constant(ThreadContext context, IRubyObject rubyName) {
+ String name = rubyName.asJavaString();
+ setConstantVisibility(context, validateConstant(name), true);
+ invalidateConstantCache(name);
return this;
}
@JRubyMethod(compat = RUBY1_9, required = 1, rest = true)
- public IRubyObject private_constant(ThreadContext context, IRubyObject[] names) {
- for (IRubyObject name : names) {
- setConstantVisibility(context, validateConstant(name.asJavaString()), true);
+ public IRubyObject private_constant(ThreadContext context, IRubyObject[] rubyNames) {
+ for (IRubyObject rubyName : rubyNames) {
+ String name = rubyName.asJavaString();
+ setConstantVisibility(context, validateConstant(name), true);
+ invalidateConstantCache(name);
}
- invalidateConstantCache();
return this;
}
@JRubyMethod(compat = RUBY1_9)
- public IRubyObject public_constant(ThreadContext context, IRubyObject name) {
- setConstantVisibility(context, validateConstant(name.asJavaString()), false);
- invalidateConstantCache();
+ public IRubyObject public_constant(ThreadContext context, IRubyObject rubyName) {
+ String name = rubyName.asJavaString();
+ setConstantVisibility(context, validateConstant(name), false);
+ invalidateConstantCache(name);
return this;
}
@JRubyMethod(compat = RUBY1_9, required = 1, rest = true)
- public IRubyObject public_constant(ThreadContext context, IRubyObject[] names) {
- for (IRubyObject name : names) {
- setConstantVisibility(context, validateConstant(name.asJavaString()), false);
+ public IRubyObject public_constant(ThreadContext context, IRubyObject[] rubyNames) {
+ for (IRubyObject rubyName : rubyNames) {
+ String name = rubyName.asJavaString();
+ setConstantVisibility(context, validateConstant(name), false);
+ invalidateConstantCache(name);
}
- invalidateConstantCache();
return this;
}
@@ -3082,7 +3085,7 @@ private IRubyObject setConstantCommon(String name, IRubyObject value, boolean wa
storeConstant(name, value);
}
- invalidateConstantCache();
+ invalidateConstantCache(name);
// if adding a module under a constant name, set that module's basename to the constant name
if (value instanceof RubyModule) {

0 comments on commit 5155146

Please sign in to comment.