Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* load.c (loaded_feature_path): cut nonsence loop execution to fix

	  performance bug.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
commit 9ce69e7cef1272c86a93eeb9a1888fe6d2a94704 1 parent 867fa45
@tarui tarui authored
Showing with 20 additions and 4 deletions.
  1. +5 −0 ChangeLog
  2. +15 −4 load.c
View
5 ChangeLog
@@ -1,3 +1,8 @@
+Wed Jun 1 06:43:13 2011 Masaya Tarui <tarui@ruby-lang.org>
+
+ * load.c (loaded_feature_path): cut nonsence loop execution to fix
+ performance bug.
+
Wed Jun 1 01:16:02 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* class.c (rb_mix_module): implement Module#mix.
View
19 load.c
@@ -73,16 +73,27 @@ loaded_feature_path(const char *name, long vlen, const char *feature, long len,
int type, VALUE load_path)
{
long i;
-
+ long plen;
+ const char *e;
+
+ if(vlen < len) return 0;
+ if (!strncmp(name+(vlen-len),feature,len)){
+ plen = vlen - len - 1;
+ } else {
+ for (e = name + vlen; name != e && *e != '.' && *e != '/'; --e);
+ if (*e!='.' ||
+ e-name < len ||
+ strncmp(e-len,feature,len) )
+ return 0;
+ plen = e - name - len - 1;
+ }
for (i = 0; i < RARRAY_LEN(load_path); ++i) {
VALUE p = RARRAY_PTR(load_path)[i];
const char *s = StringValuePtr(p);
long n = RSTRING_LEN(p);
- if (vlen < n + len + 1) continue;
+ if (n != plen ) continue;
if (n && (strncmp(name, s, n) || name[n] != '/')) continue;
- if (strncmp(name + n + 1, feature, len)) continue;
- if (name[n+len+1] && name[n+len+1] != '.') continue;
switch (type) {
case 's':
if (IS_DLEXT(&name[n+len+1])) return p;
Please sign in to comment.
Something went wrong with that request. Please try again.