merges r31875 from trunk into ruby_1_9_2.

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@32882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
yugui 2011-08-07 10:04:22 +00:00
parent c88e3861e1
commit a5729b15f3
3 changed files with 20 additions and 4 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.
Sat Jun 25 23:45:30 2011 CHIKANAGA Tomoyuki <nagachika00@gmail.com> Sat Jun 25 23:45:30 2011 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
* vm_insnhelper.c (vm_search_superclass): avoid control frame * vm_insnhelper.c (vm_search_superclass): avoid control frame

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) int type, VALUE load_path)
{ {
long i; 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) { for (i = 0; i < RARRAY_LEN(load_path); ++i) {
VALUE p = RARRAY_PTR(load_path)[i]; VALUE p = RARRAY_PTR(load_path)[i];
const char *s = StringValuePtr(p); const char *s = StringValuePtr(p);
long n = RSTRING_LEN(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 (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) { switch (type) {
case 's': case 's':
if (IS_DLEXT(&name[n+len+1])) return p; if (IS_DLEXT(&name[n+len+1])) return p;

View file

@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.2" #define RUBY_VERSION "1.9.2"
#define RUBY_PATCHLEVEL 293 #define RUBY_PATCHLEVEL 294
#define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1 #define RUBY_VERSION_TEENY 1