Created
June 5, 2011 13:05
-
-
Save taf2/1008945 to your computer and use it in GitHub Desktop.
Ruby 1.9.2-p180 require performance patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/load.c 2010-10-23 05:36:38.000000000 -0400 | |
+++ b/patchload.c 2011-06-05 08:58:00.000000000 -0400 | |
@@ -40,14 +40,6 @@ | |
VALUE ary; | |
long i; | |
- for (i = 0; i < RARRAY_LEN(load_path); ++i) { | |
- VALUE str = rb_check_string_type(RARRAY_PTR(load_path)[i]); | |
- if (NIL_P(str) || !rb_is_absolute_path(RSTRING_PTR(str))) | |
- goto relative_path_found; | |
- } | |
- return load_path; | |
- | |
- relative_path_found: | |
ary = rb_ary_new2(RARRAY_LEN(load_path)); | |
for (i = 0; i < RARRAY_LEN(load_path); ++i) { | |
VALUE path = rb_file_expand_path(RARRAY_PTR(load_path)[i], Qnil); | |
@@ -81,16 +73,27 @@ | |
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/load.c 2010-10-23 05:36:38.000000000 -0400 | |
+++ b/patchload.c 2011-06-05 08:58:00.000000000 -0400 | |
@@ -81,16 +73,27 @@ | |
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; |
The patch is failing for me using RVM and 1.9.2 . Did I get the wrong version? where do I find the ruby-1.9.2p290.patch?
[2011-10-27 15:40:24] patch -F25 -p1 -f <"/home/emmanuel/require.patch"
patching file load.c
Hunk #1 FAILED at 40.
Hunk #2 succeeded at 73 (offset -8 lines).
1 out of 2 hunks FAILED -- saving rejects to file load.c.rej
~
@epinault-ttc I wouldn't recommend using any of these any more, these patchsets work great: https://github.com/skaes/rvm-patchsets
@aaronjensen: Thanks! seems to work now
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Bregor, i attached the updated patch it's actually much smaller: ruby-1.9.2p290.patch