Skip to content

Commit

Permalink
Merge pull request jruby#34 from bigfix/require_performance
Browse files Browse the repository at this point in the history
Improve require performance.

See JRUBY-5320.
  • Loading branch information
nicksieger committed May 6, 2011
2 parents 4705f9e + a3afa94 commit f9702e7
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/org/jruby/runtime/load/LoadService.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyFile;
import org.jruby.RubyFixnum;
import org.jruby.RubyHash;
import org.jruby.RubyInstanceConfig;
import org.jruby.RubyString;
Expand Down Expand Up @@ -459,10 +460,11 @@ public void removeInternalLoadedFeature(String name) {
if (caseInsensitiveFS) {
// on a case-insensitive filesystem, we need to search case-insensitively
// to remove the loaded feature
for (Iterator iter = loadedFeaturesInternal.iterator(); iter.hasNext();) {
Object feature = iter.next();
if (feature.toString().equalsIgnoreCase(name)) {
iter.remove();
RubyString nameRubyString = runtime.newString(name);
for (int i = 0; i < loadedFeatures.size(); i++) {
RubyString feature = loadedFeatures.eltInternal(i).convertToString();
if (((RubyFixnum)feature.casecmp(runtime.getCurrentContext(), nameRubyString)).getLongValue() == 0) {
loadedFeatures.remove(i);
}
}
} else {
Expand All @@ -472,12 +474,11 @@ public void removeInternalLoadedFeature(String name) {

protected boolean featureAlreadyLoaded(RubyString loadNameRubyString) {
if (caseInsensitiveFS) {
String name = loadNameRubyString.toString();
// on a case-insensitive filesystem, we need to search case-insensitively
// to find the loaded feature
for (Iterator iter = loadedFeaturesInternal.iterator(); iter.hasNext();) {
Object feature = iter.next();
if (feature.toString().equalsIgnoreCase(name)) {
for (int i = 0; i < loadedFeatures.size(); i++) {
RubyString feature = loadedFeatures.eltInternal(i).convertToString();
if (((RubyFixnum)feature.casecmp(runtime.getCurrentContext(), loadNameRubyString)).getLongValue() == 0) {
return true;
}
}
Expand Down

0 comments on commit f9702e7

Please sign in to comment.