1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
tarui 2011-05-31 21:56:01 +00:00
parent 867fa454d8
commit 9ce69e7cef
2 changed files with 19 additions and 3 deletions

View file

@ -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.

17
load.c
View file

@ -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;